Does shuffle() produce uniform result ?
tooru honda
tooru_honda at fast-mail.org
Sat Aug 25 08:35:52 EDT 2007
At the end, I think it is worthwhile to implement my own shuffle and
random methods based on os.urandom. Not only does the resulting code
gets rid of the minuscule bias, but the program also runs much faster.
When using random.SystemRandom.shuffle, posix.open and posix.close from
calling os.urandom account for almost half of the total execution time
for my program. By implementing my own random and getting a much larger
chunk of random bytes from os.urandom each time, I am able to reduce the
total execution time by half.
-tooru honda
P.S. I use python 2.5.1 on MacOSX 10.4.10 (PowerPC).
More information about the Python-list
mailing list