Permanent objects?

Armin Steinhoff a-steinhoff at web.de
Sat Dec 28 07:30:11 EST 2002


Paul Rubin <phr-n2002b at NOSPAMnightsong.com> wrote in message news:<7xy96ee7r2.fsf at ruckus.brouhaha.com>...
> 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.

Thanks .. it's now much clearer.

Armin



More information about the Python-list mailing list