[New-bugs-announce] [issue29085] Python 3.6 on Windows doesn't seed Random() well enough

Ned Batchelder report at bugs.python.org
Tue Dec 27 12:39:24 EST 2016


New submission from Ned Batchelder:

Creating two Random() instances in quick succession produces the same sequence, but only on Windows on Python 3.6.  On 3.5 or earlier, or on Mac/Linux, the randomization is good.

Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import random; print(random.Random().randint(1, 999999), random.Random().randint(1, 999999))
903885 903885
>>> import random; print(*[random.Random().randint(1, 999999) for _ in range(2)])
996947 56476
>>> import random; print(*[random.Random().randint(1, 999999) for _ in range(2)])
793282 793282
>>> import random; print(*[random.Random().randint(1, 999999) for _ in range(2)])
519702 519702
>>> import random; print(*[random.Random().randint(1, 999999) for _ in range(2)])
230678 230678
>>> import random; print(*[random.Random().randint(1, 999999) for _ in range(3)])
474701 474701 474701
>>> import random; print(*[random.Random().randint(1, 999999) for _ in range(3)])
890942 890942 890942
>>> import random; print(*[random.Random().randint(1, 999999) for _ in range(3)])
997495 997495 997495
>>> import random; print(*[random.Random().randint(1, 999999) for _ in range(5)])
27803 27803 27803 27803 919401
>>>

I would expect each of these runs to produce unique numbers, with no duplicates.

----------
keywords: 3.6regression
messages: 284118
nosy: nedbat
priority: normal
severity: normal
status: open
title: Python 3.6 on Windows doesn't seed Random() well enough

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


More information about the New-bugs-announce mailing list