"/a" is not "/a" ?

Lie Ryan lie.1296 at gmail.com
Sat Mar 7 05:18:52 EST 2009


Steven D'Aprano wrote:
> Albert Hopkins wrote:
> 
>> I would think (not having looked) that the implementation of == would
>> first check for identity (for performance reasons)...
> 
> For some types, it may. I believe that string equality testing first tests
> whether the two strings are the same string, then tests if they have the
> same hash, and only then do a character-by-character comparison. Or so I've
> been told.
> 
>> can an object be identical but not equal to itself?
> 
> Yes. Floating point NANs are required to compare unequal to all floats,
> including themselves. It's part of the IEEE standard.

btw, have anybody noticed that the subject line "/a" is not "/a" is 
actually False.

 >>> "/a" is not "/a"
False
 >>> a = "/a"
 >>> b = "/a"
 >>> a is not b
True



More information about the Python-list mailing list