'==' vs. 'is' behavior
Skip Montanaro
skip at mojam.com
Fri Nov 12 10:56:40 EST 1999
Andy> Further experimentation shows that this seems to work for integers
Andy> through 99, but that starting with 100 the results of the 'is'
Andy> test return 0, as I would expect.
Python's intobject.c file maintains a cache of the integer objects 0 through
99. If you check the id() of small integers you'll see they are always
represented by the same object.
read-the-source-luke-ly y'rs,
Skip Montanaro | http://www.mojam.com/
skip at mojam.com | http://www.musi-cal.com/
847-971-7098 | Python: Programming the way Guido indented...
More information about the Python-list
mailing list