negative numbers are not equal...

ariel ledesma fayuca at gmail.com
Thu Aug 14 17:23:21 EDT 2008



Christian Heimes wrote:
> You are getting the result because Python optimized small integers. 
> See http://svn.python.org/projects/python/trunk/Objects/intobject.c 
> Integers between -5 and +256 are singletons as are some other objects 
> like strings with one element or empty tuples. You must not rely on 
> the optimization.
>

i see now, so i guess that's also why id() returns the same address for 
them as well...
i'll dive into the implementation file, it may be a bit out of my league 
but i'll see what i can gather, and hey, that's how it works, right? :-)

thanks

ariel



More information about the Python-list mailing list