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 <1276863732.9.0.202368142527.issue9025@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2010-06-18 12:22:12mark.dickinsonsetrecipients: + mark.dickinson, rhettinger
2010-06-18 12:22:12mark.dickinsonsetmessageid: <1276863732.9.0.202368142527.issue9025@psf.upfronthosting.co.za>
2010-06-18 12:22:11mark.dickinsonlinkissue9025 messages
2010-06-18 12:22:11mark.dickinsoncreate