difference between random module in python 2.6 and 3.2?

Terry Reedy tjreedy at udel.edu
Mon Feb 6 08:27:14 CET 2012


On 2/6/2012 12:56 AM, Steven D'Aprano wrote:
> On Mon, 06 Feb 2012 00:07:04 -0500, Terry Reedy wrote:
>
>> On 2/5/2012 11:01 PM, Steven D'Aprano wrote:
>>
>>> Reading the docs, I would expect that when using an int as seed, you
>>> should get identical results.
>>
>> That is similar to expecting hash to be consistent from version to
>> version.
>
> No. hash is not intended to be consistent across versions, or even across

Oh, but it was. Changing it will break tests, including some in the 
Python test suite.

...
> This, plus Raymond Hettinger's comments on the bug report, make me think
> that the change in behaviour of randrange and choice is not deliberate

As I said, it was a necessary consequence of a bug fix.

> 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. 
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.

-- 
Terry Jan Reedy




More information about the Python-list mailing list