Amaury Forgeot d'Arc <amaur...@gmail.com> added the comment: ./python -m timeit -s "from random import getrandbits" "getrandbits(8000000).to_bytes(1000000, 'little')" 10 loops, best of 3: 25 msec per loop
./python -m timeit -s "from random import getrandbytes" "getrandbytes(1000000)" 100 loops, best of 3: 9.66 msec per loop For the Mersenne Twister, getrandbytes() is ~2.5 times faster (A length of 1000 gives exactly the same ratio) When applied to the SytemRandom object, the difference is less impressive (probably because os.urandom is slow) but getrandbytes is still 20ms faster. Updated patch to add getrandbytes at the module level, and to SystemRandom. ---------- Added file: http://bugs.python.org/file23682/getrandbytes.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13396> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com