On 8/27/07, Peter Otten <[EMAIL PROTECTED]> wrote: > Peter Otten wrote: > > > Alex Martelli wrote: > > > >> Integer objects that are once generated are kept around in a "free list" > >> against the probability that they might be needed again in the future (a > > > > 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. > >>>> x = 1000 > >>>> y = 1000 > >>>> x is y > > False > > Why don't x and y point to the same object then? > > Peter > Oops, I think I got it now. The actual objects are freed, only the memory is > kept around for reuse with other ints...
On my (windows) machine, only integer up to 256 are cached... I made two dictionaries with mapping from i to id(i) and then compared. They were equal up to 256. In short, try your example with 256 and 257 and see what happens :-) francesco -- http://mail.python.org/mailman/listinfo/python-list