Mutable numbers

Fredrik Lundh fredrik at pythonware.com
Tue Feb 21 10:31:50 EST 2006


Steve Holden wrote:

> > The memory allocation for integers is optimized. 'Small' integers
> > (between -5 and 100 IIRC) are allocated once and reused. The memory for
> > larger integers is allocated once and reused whenever possible, so the
> > malloc() overhead is negligible.
>
> The first bit's right, the second bit isn't:
>
>   >>> id(12100)
> 4604168
>   >>> id(121*100)
> 4604204
>   >>>

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/

-- 
http://mail.python.org/mailman/listinfo/python-list






More information about the Python-list mailing list