python preallocate some integers?

Alex Martelli aleaxit at
Tue Oct 19 23:45:20 CEST 2004

Dave Reed <drlinux at> wrote:

> I seem to recall somewhere, possibly in the Python Essential Reference
> (but unfortunately, books don't have a "find" function), that Python
> preallocates and never destroys the first 100 integers. A minute of
> google searching didn't help me so I tried some simple tests. Based on
> these, it appears that only one copy of the integers -5 through 99 is
> created.
> Can someone please verify this for me or tell me what is done with
> regard to this?

In the current implementation, that is indeed the case.  Of course,
since it's strictly an optimization issue, that's a detail which could
change even between one subrelease and the next, so make sure your
application doesn't depend on it.


More information about the Python-list mailing list