Mutable numbers
fraca7
fraca7 at free.fr
Tue Feb 21 09:33:17 EST 2006
Suresh Jeevanandam a écrit :
> # I am new to python.
>
> In python all numbers are immutable. This means there is one object ( a
> region in the memory ) created every time we do an numeric operation. I
> hope there should have been some good reasons why it was designed this way.
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.
More information about the Python-list
mailing list