[Tutor] Memory Problem

Abel Daniel abli@freemail.hu
Fri Jul 4 02:04:01 2003


Magnus Lyck? wrote:
> If you just use xrange() instead of range(), you won't create any
> list, but I don't know if Python will actually release the memory
> used for integers, since they are interned. (That integers are interned
> means that if you use 42 in several different places in your code, it
> will always use the same integer object.)
Isn't this only done for small ( < 100) integers?

>>> a=99
>>> b=99
>>> id(a)
135432252
>>> id(b)
135432252
>>> a=100
>>> b=100
>>> id(a)
135431964
>>> id(b)
135432000

Abel Daniel