[BangPypers] python id function
Anand Balachandran Pillai
abpillai at gmail.com
Thu Jan 7 10:15:44 CET 2010
On Thu, Jan 7, 2010 at 2:16 PM, Anand Balachandran Pillai <
abpillai at gmail.com> wrote:
> It is a good exercise to find out the limit till Python caches
> integers. My guess is that it is somewhere close to 100, i.e
I wrote a small program to find this out. And
on my Python runtime (2.6.2), the answer is 257.
if x is not y:
[anand at localhost python]$ python
Python 2.6.2 (r262:71600, Aug 21 2009, 12:23:57)
[GCC 4.4.1 20090818 (Red Hat 4.4.1-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from intlimit import *
So Python caches integers till 256 - a nice square integer.
Cool right ?
Others can try it out in other Python versions - my guess
would be it is the same everywhere.
More information about the BangPypers