[issue23974] random.randrange() biased output

Raymond Hettinger report at bugs.python.org
Tue Apr 21 05:25:22 CEST 2015


Raymond Hettinger added the comment:

> we *still* have no documented guarantees of reproducibility,
> so maybe it's safe to go ahead and change this.  Raymond?

It is documented here:  https://docs.python.org/3/library/random.html#notes-on-reproducibility

The idea that is that algorithms (and the generated sequences) may change in between minor releases, but not in micro releases.  And random() itself if more restricted (guaranteed to be the same across minor releases as well).  The policy was new in Python 3.  It was a liberalization of the implied policy in Python 2 that we didn't change the sequences at all (except for flat-out brokenness).

Accordingly, the #9025 debiasing was intentionally not backported so we won't break reproducibility and adversely affect performance of existing code.

We could add a note as Mark suggests, but please keep it terse and affirmatively worded (perhaps something "See also:  Recipe 31xx for a way to eliminate rounding biases in randrange()".  The docs are not well served by being littered with Danger-signs and security warnings.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23974>
_______________________________________


More information about the Python-bugs-list mailing list