Mutable numbers

fraca7 fraca7 at free.fr
Tue Feb 21 10:50:07 EST 2006


Steve Holden a écrit :

> [Thinks: or maybe fraca7 just meant that integers will be garbage 
> collected when there are no more references to them].

Actually I meant that the memory is reused, but the same integer won't 
always have the same address.

I guess that in your example, the '121' is assigned the 'old' address of 
12100, and the result of the operation is assigned the next chunk; the 
following seems to confirm that:

  >>> id(12100)
  8628480
  >>> id(102)
  8628480



More information about the Python-list mailing list