This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Geraldo.Xexeo
Recipients Geraldo.Xexeo, Shane Smith
Date 2019-04-11.01:31:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1554946277.94.0.0104096098176.issue36592@roundup.psfhosted.org>
In-reply-to
Content
"So 2**8 is a magic number, for whatever reason."

Actually, this is true. Accordingly to https://rushter.com/blog/python-integer-implementation/

"Optimization of commonly-used integers
Small integer objects in a range of -5 to 256 are always pre-allocated during initialization. Because Python integers are immutable, we can use them as singletons. Every time you need to create small integer instead of creating new object Python just points to already allocated one. Thereby it saves a lot of space and computation for commonly-used integers.

Interestingly enough, the PyLongObject structure takes at least 28 bytes for every allocated integer and therefore takes three times as much memory as a simple 64-bit C integer."

This are constants 

#define NSMALLPOSINTS           257
#define NSMALLNEGINTS           5

You can find the code in:

https://github.com/python/cpython/blob/master/Objects/longobject.c
History
Date User Action Args
2019-04-11 01:31:17Geraldo.Xexeosetrecipients: + Geraldo.Xexeo, Shane Smith
2019-04-11 01:31:17Geraldo.Xexeosetmessageid: <1554946277.94.0.0104096098176.issue36592@roundup.psfhosted.org>
2019-04-11 01:31:17Geraldo.Xexeolinkissue36592 messages
2019-04-11 01:31:17Geraldo.Xexeocreate