mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
SF bug #778964: bad seed in python 2.3 random
The default seed is time.time(). Multiplied by 256 before truncating so that fractional seconds are used. This way, two successive calls to random.seed() are much more likely to produce different sequences.
This commit is contained in:
parent
39a682f5f2
commit
3081d59f92
3 changed files with 8 additions and 1 deletions
|
@ -94,6 +94,9 @@ class Random(_random.Random):
|
|||
If a is not None or an int or long, hash(a) is used instead.
|
||||
"""
|
||||
|
||||
if a is None:
|
||||
import time
|
||||
a = long(time.time() * 256) # use fractional seconds
|
||||
super(Random, self).seed(a)
|
||||
self.gauss_next = None
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue