Terry J. Reedy <tjre...@udel.edu> added the comment:

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.

----------
nosy: +terry.reedy

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11846>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to