bod...@googlemail.com wrote:
And presumably cleans up the leftover object with the value of 42 when it 
changes to point at the 43 object?

In principle, yes, the garbage collector will destroy the no-longer used object 42 once nothing is pointing to it any more.

But in practice, Python caches "small integers", where the definition of small depends on which version of Python you are using, on the basis that it's better to hang onto them in a cache for re-use than to keep making and destroying them over and over again. This is a classic "time versus space" trade-off: using extra memory to save time.



--
Steven
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to