Message339913
"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 |
|
Date |
User |
Action |
Args |
2019-04-11 01:31:17 | Geraldo.Xexeo | set | recipients:
+ Geraldo.Xexeo, Shane Smith |
2019-04-11 01:31:17 | Geraldo.Xexeo | set | messageid: <1554946277.94.0.0104096098176.issue36592@roundup.psfhosted.org> |
2019-04-11 01:31:17 | Geraldo.Xexeo | link | issue36592 messages |
2019-04-11 01:31:17 | Geraldo.Xexeo | create | |
|