➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 amaury.forgeotdarc
收信人 amaury.forgeotdarc, nadeem.vawda, pitrou, rhettinger
日期 2011-11-13.21:14:57
SpamBayes Score 2.856632e-07
Marked as misclassified 否
Message-id <1321218898.3.0.176661098379.issue13396@psf.upfronthosting.co.za>
In-reply-to
内容
./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.
历史
日期 用户 动作 参数
2011-11-13 21:14:58amaury.forgeotdarc修改recipients: + amaury.forgeotdarc, rhettinger, pitrou, nadeem.vawda
2011-11-13 21:14:58amaury.forgeotdarc修改messageid: <1321218898.3.0.176661098379.issue13396@psf.upfronthosting.co.za>
2011-11-13 21:14:57amaury.forgeotdarc链接issue13396 messages
2011-11-13 21:14:57amaury.forgeotdarc创建