Permanent objects?
Erik Max Francis
max at alcyone.com
Tue Dec 24 19:26:32 EST 2002
Tom Zych wrote:
> I'm guessing that Python keeps the integers from -1 to 99 as
> permanent objects so it doesn't have to create a brand new object
> for every piddling little [0] and such. Anyone know?
Yes (or something along those lines; you could check the source code for
the final word). This optimization is really an implementation detail,
however; since these objects are immutable, tests for == vs. is are
really irrelevant and code should never rely on any such behavior of is
vs. ==.
In short, pay no attention to the man behind the curtain.
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ Dead men have no victory.
\__/ Euripides
Bosskey.net: Aliens vs. Predator 2 / http://www.bosskey.net/avp2/
A personal guide to Aliens vs. Predator 2.
More information about the Python-list
mailing list