fraca7 wrote: > 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.
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