Antoine Pitrou <pit...@free.fr> added the comment: > Randomness is hard to do correctly > and is expensive. If we can avoid it, we should try very hard to do > so...
os.urandom() is actually cheaper on Windows 7 here: 1000000 loops, best of 3: 1.78 usec per loop than on Linux: $ ./python -m timeit -s "import os" "os.urandom(16)" 100000 loops, best of 3: 4.85 usec per loop $ ./python -m timeit -s "import os; f=os.open('/dev/urandom', os.O_RDONLY)" "os.read(f, 16)" 100000 loops, best of 3: 2.35 usec per loop (note that the os.read timing is optimistic since I'm not checking the return value!) I don't know if the patch's startup overhead has to do with initializing the crypo context or simply with looking up the symbols in advapi32.dll. Perhaps we should link explicitly against advapi32.dll as suggested by Martin? ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13703> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com