Permanent objects?
Erik Max Francis
max at alcyone.com
Wed Dec 25 05:21:19 EST 2002
More information about the Python-list mailing list
Wed Dec 25 05:21:19 EST 2002
- Previous message (by thread): Permanent objects?
- Next message (by thread): Permanent objects?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Armin Steinhoff wrote: > Could someone explain in _detail_ why this happens? As an optimization. Since integer objects are immutable, when you ask for an object representing, say, the number 2, it doesn't matter whether or not that object is a physically different object from others representing the same number, since it's immutable. Compare that, say, with a list object: Since lists are mutable, it definitely does make a difference whether any given empty list (say) is the same object as any other empty list. Since small integers get created a lot, it sometimes make sense to precache the creation of those objects and simply use the same physical object, rather than going to the expense of creating a new one (with the overhead of the allocation of memory, etc.) each time. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE / \ Punctuality is the virtue of the bored. \__/ Evelyn Waugh Computer science / http://www.alcyone.com/max/reference/compsci/ A computer science reference.
- Previous message (by thread): Permanent objects?
- Next message (by thread): Permanent objects?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list