Surprise using the 'is' operator

tobiah toby at tobiah.org
Wed Sep 27 11:26:28 EDT 2006


wesley chun wrote:
>> "Terry Reedy" <tjr... at udel.edu> wrote:
>> > as a side note, the ints that are cached (for current versions of
>> > Python) are in range(-1, 100)... is this documented somewhere?
>> Not true for at least 2.4 and 2.5.  The cached range has expanded
> 
> oops, apologies to all... it really *is* subject to change. ;-) it's
> now range(-5, 257).
> 
> -wesley

I don't pretend to understand the reasons for all of this,
but if it is possible to use the same integer object whenever
it is referenced, then why should there be a limit on range?

Suppose I fill an list with 100 million random integers in the range
of 1 - 65535.  Wouldn't I save much memory if all of the ocurrances
of '12345' pointed to the same integer object?  Why should more be made,
when they all do the same thing, and are not subject to change?

Thanks,

Tobiah

-- 
Posted via a free Usenet account from http://www.teranews.com




More information about the Python-list mailing list