I came across the topic of internal Python IDs recently, and learned that the 
internal numeric ids of small integers are cached to increase speed. I had read 
that as of 2.5, this applied to integers between -1 and 100. However, doing 
some quick tests, this seems not to be accurate:

Python 2.5.1 (r251:54863, May  2 2007, 16:56:35) 
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 10
>>> b = 10
>>> print id(a), id(b)
135716556 135716556
>>> c = 250
>>> d = 250
>>> print id(c), id(d)
135719604 135719604
>>> e = 300
>>> f = 300
>>> print id(e), id(f)
135718812 135718824

So the upper end of the interning range appears to be between 250 and 300, not 
100.

Does anyone know the exact number, when it changed, and if a decision has been 
made for future changes? I was unable to find anything specific to this in the 
documentation.

Thanks as always,
Sam

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to