Author rhettinger
Recipients rhettinger, serhiy.storchaka
Date 2015-02-20.10:18:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1424427522.46.0.066480034722.issue23488@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2015-02-20 10:18:42rhettingersetrecipients: + rhettinger, serhiy.storchaka
2015-02-20 10:18:42rhettingersetmessageid: <1424427522.46.0.066480034722.issue23488@psf.upfronthosting.co.za>
2015-02-20 10:18:42rhettingerlinkissue23488 messages
2015-02-20 10:18:41rhettingercreate