Message108101
Here's an example patch that removes any bias from randrange(n) (except for bias resulting from the imperfectness of the core MT generator). I added a small private method to Modules/_randommodule.c to aid the computation.
This only fixes one instance of int(random() * n) in the Lib/random.py source; the other instances should be modified accordingly.
With this patch, randrange is a touch faster than before (20-30% speedup) for small arguments.
Is this worth pursuing? |
|
Date |
User |
Action |
Args |
2010-06-18 12:22:12 | mark.dickinson | set | recipients:
+ mark.dickinson, rhettinger |
2010-06-18 12:22:12 | mark.dickinson | set | messageid: <1276863732.9.0.202368142527.issue9025@psf.upfronthosting.co.za> |
2010-06-18 12:22:11 | mark.dickinson | link | issue9025 messages |
2010-06-18 12:22:11 | mark.dickinson | create | |
|