Author terry.reedy
Recipients antlong, dmalcolm, eric.araujo, ezio.melotti, nedbat, pitrou, rhettinger, terry.reedy
Date 2011-04-25.18:45:57
SpamBayes Score 0.000131375
Marked as misclassified No
Message-id <1303757159.56.0.644157720301.issue11846@psf.upfronthosting.co.za>
In-reply-to
Content
The range of interned ints was once much smaller, but it was expanded upwards to 256 so that the bytes extracted from bytes and bytearray objects, as when indexing or iterating, would *all* be pre-allocated objects. I should presume that their indexers and iterators are cognizant of this and take advantage of this to bypass int() creation and directly index into the the array of preallocated ints without a range check.

As for space and some time saving, just on startup,
a nearly fresh IDLE shell shows

>>> sum((sys.getrefcount(i) for i in range(-5, 257)))
4432

There are hundreds of references for each of 0 and 1.
History
Date User Action Args
2011-04-25 18:45:59terry.reedysetrecipients: + terry.reedy, rhettinger, pitrou, nedbat, ezio.melotti, eric.araujo, dmalcolm, antlong
2011-04-25 18:45:59terry.reedysetmessageid: <1303757159.56.0.644157720301.issue11846@psf.upfronthosting.co.za>
2011-04-25 18:45:57terry.reedylinkissue11846 messages
2011-04-25 18:45:57terry.reedycreate