[issue23488] Random objects twice as big as necessary on 64-bit builds
Raymond Hettinger
report at bugs.python.org
Fri Feb 20 11:18:42 CET 2015
New submission from Raymond Hettinger:
The Modules/_randommodule.c implements the 32-bit version of the MersenneTwister and its struct uses (unsigned long) for each of the 624 elements of the state vector.
On a 32-bit build, the unsigned longs are 4 bytes. However, on a 64-bit build, they are 8 bytes each eventhough only the bottom 32-bits are used. This causes the random object to be twice as big as necessary. sys.getsizeof(_random.Random()) reports 5016 bytes. This wastes memory, grinds the cache, and slows performance.
The (unsigned long) declaration should probably be replaced with (uint32_t).
----------
assignee: rhettinger
messages: 236262
nosy: rhettinger, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Random objects twice as big as necessary on 64-bit builds
type: resource usage
versions: Python 2.7, Python 3.4, Python 3.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23488>
_______________________________________
More information about the Python-bugs-list
mailing list