difference between random module in python 2.6 and 3.2?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Feb 6 09:05:43 CET 2012

On Mon, 06 Feb 2012 02:27:14 -0500, Terry Reedy wrote:

>> and should be treated as a bug. Raymond made a strong case arguing for
>> repeatability, and then approved a bug fix that broke repeatability. I
>> doubt that was deliberate.
> It was deliberate that randrange was changed to an even distribution
> from a slightly uneven distribute. That implies a change in the pattern.

Okay, granted.

> That was known and the main subject of discussion. As Antoine said,
> making functions exactly repeatable across versions means not fixing
> bugs or otherwise improving them. This statement is not limited to the
> random module.
> You have persuaded me that the doc should be more explicit that while
> the basic random.random sequence will be kept repeatable with seed set
> (except perhaps after a changeover of several releases), the convenience
> transformations can be changed if improvements are needed or thought
> sufficiently desirable.

A more explicit note will help, but the basic problem applies: how do you 
write deterministic tests given that the random.methods (apart from 
random.random itself) can be changed without warning?


More information about the Python-list mailing list