[New-bugs-announce] [issue16674] Faster getrandbits() for small integers

Serhiy Storchaka report at bugs.python.org
Thu Dec 13 21:54:36 CET 2012

New submission from Serhiy Storchaka:

The proposed patch adds a fast patch for generating small integers (the most common use case).

$ ./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

components: Extension Modules
files: random_getrandbits_fastpath.patch
keywords: patch
messages: 177436
nosy: mark.dickinson, rhettinger, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Faster getrandbits() for small integers
type: performance
versions: Python 3.4
Added file: http://bugs.python.org/file28304/random_getrandbits_fastpath.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list