Permanent objects?
Paul Rubin
phr-n2002b at NOSPAMnightsong.com
Wed Dec 25 05:02:41 EST 2002
a-steinhoff at web.de (Armin Steinhoff) writes:
> > > >>> x = 99
> > > >>> y = 99
> > > >>> x is y
> > 1
> > > >>> x = 100
> > > >>> y = 100
> > > >>> x is y
> > > 0
>
> Could someone explain in _detail_ why this happens?
Python heap-allocates numeric objects including integers. Integers
less than 100 are cached in a table, sort of like interned strings,
since they're used frequently. Integers >= 100 get newly allocated
since they're more likely to be unique.
More information about the Python-list
mailing list