Interesting behaviour of the assignment

Aahz Maruch aahz at panix.com
Sat Dec 30 00:42:14 CET 2000


In article <92j4n1$mhu$0 at 216.39.162.232>,
Michael Esveldt  <dante at oz.net> wrote:
>[Thomas Wouters]
>>
>> In other words, 'x == y' first does 'x is y', and if it's true, the
>> result of the operation is true. Only if 'x is y' is false will it
>> start the (possibly very expensive) comparison-by-contents operation.
>
>This is a somewhat ignorant question, but if 'x == y' checks for 'x is
>y' first, why use 'is' at all? If you only get a tiny bit of speed out
>of using 'is' is it worth it to have this in the language at all? (Not
>that it would ever change, just curious.)

Because sometimes you really do want to know if two objects are the same
(rather than simply being equal).  If you drop "is", you can't check for
object identity.
-- 
                      --- Aahz (Copyright 2000 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

Ninth Virtual Anniversary: 2 days and counting



More information about the Python-list mailing list