Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9cb018e

Browse files
committed
Change the default seeding -- use 8 bits of sub-second precision and
fold in the higest 8 bits of the time as well.
1 parent b6685dc commit 9cb018e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Lib/whrandom.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def seed(self, x = 0, y = 0, z = 0):
4949
if 0 == x == y == z:
5050
# Initialize from current time
5151
import time
52-
t = int(time.time() % 0x80000000)
52+
t = long(time.time() * 256)
53+
t = int((t&0xffffff) | (t>>24))
5354
t, x = divmod(t, 256)
5455
t, y = divmod(t, 256)
5556
t, z = divmod(t, 256)

0 commit comments

Comments
 (0)