Message134401
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. |
|
Date |
User |
Action |
Args |
2011-04-25 18:45:59 | terry.reedy | set | recipients:
+ terry.reedy, rhettinger, pitrou, nedbat, ezio.melotti, eric.araujo, dmalcolm, antlong |
2011-04-25 18:45:59 | terry.reedy | set | messageid: <1303757159.56.0.644157720301.issue11846@psf.upfronthosting.co.za> |
2011-04-25 18:45:57 | terry.reedy | link | issue11846 messages |
2011-04-25 18:45:57 | terry.reedy | create | |
|