mirror of https://github.com/python/cpython.git
Change the default seeding -- use 8 bits of sub-second precision and
fold in the higest 8 bits of the time as well.
This commit is contained in:
parent
b6685dcfeb
commit
9cb018e693
|
@ -49,7 +49,8 @@ def seed(self, x = 0, y = 0, z = 0):
|
||||||
if 0 == x == y == z:
|
if 0 == x == y == z:
|
||||||
# Initialize from current time
|
# Initialize from current time
|
||||||
import time
|
import time
|
||||||
t = int(time.time() % 0x80000000)
|
t = long(time.time() * 256)
|
||||||
|
t = int((t&0xffffff) | (t>>24))
|
||||||
t, x = divmod(t, 256)
|
t, x = divmod(t, 256)
|
||||||
t, y = divmod(t, 256)
|
t, y = divmod(t, 256)
|
||||||
t, z = divmod(t, 256)
|
t, z = divmod(t, 256)
|
||||||
|
|
Loading…
Reference in New Issue