Issue 16674: Faster getrandbits() for small integers (original ) (raw ) This issue has been migrated to GitHub: https://github.com/python/cpython/issues/60878
classification
process
Created on 2012-12-13 20:54 by serhiy.storchaka , last changed 2022-04-11 14:57 by admin . This issue is now closed .
Messages (3)
msg177436 - (view)
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2012-12-13 20:54
The proposed patch adds a fast patch for generating small integers (the most common use case). Microbenchmark: $ ./python -m timeit -s "import random; r=random.getrandbits; n=30" "r(n);r(n);r(n);r(n);r(n);r(n);r(n);r(n);r(n);r(n)" Non patched: 4.27 usec per loop Patched: 2.97 usec per loop
msg178990 - (view)
Author: Mark Dickinson (mark.dickinson) *
Date: 2013-01-03 21:33
Looks good to me.
msg179012 - (view)
Author: Roundup Robot (python-dev)
Date: 2013-01-04 10:20
New changeset b0926ddcab5e by Serhiy Storchaka in branch 'default': Issue #16674 : random.getrandbits() is now 20-40% faster for small integers. http://hg.python.org/cpython/rev/b0926ddcab5e
History
Date
User
Action
Args
2022-04-11 14:57:39
admin
set
github: 60878
2013-01-04 10:21:59
serhiy.storchaka
set
status: open -> closedresolution: fixedstage: patch review -> resolved
2013-01-04 10:20:54
python-dev
set
nosy: + python-dev messages: +
2013-01-03 21:33:42
mark.dickinson
set
messages: +
2012-12-29 21:59:50
serhiy.storchaka
set
assignee: serhiy.storchaka
2012-12-13 21:23:27
jcea
set
nosy: + jcea
2012-12-13 20:54:36
serhiy.storchaka
create