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.

Author mark.dickinson
Recipients mark.dickinson, rhettinger
Date 2010-06-18.12:22:11
SpamBayes Score 2.46428e-05
Marked as misclassified No
Message-id <>
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/ 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:12mark.dickinsonsetrecipients: + mark.dickinson, rhettinger
2010-06-18 12:22:12mark.dickinsonsetmessageid: <>
2010-06-18 12:22:11mark.dickinsonlinkissue9025 messages
2010-06-18 12:22:11mark.dickinsoncreate