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 <rep...@bugs.python.org>
<http://bugs.python.org/issue23488>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to