'==' vs. 'is' behavior
skip at mojam.com
Fri Nov 12 16:56:40 CET 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.
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