]> granicus.if.org Git - python/commitdiff
Change the default seeding -- use 8 bits of sub-second precision and
authorGuido van Rossum <guido@python.org>
Mon, 21 Oct 1996 23:20:03 +0000 (23:20 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 21 Oct 1996 23:20:03 +0000 (23:20 +0000)
fold in the higest 8 bits of the time as well.

Lib/whrandom.py

index 8ed39c923cd0e5f9902c6e99782f82c20eed14af..3cc15323b558622bb1bee68340605d599735d104 100644 (file)
@@ -49,7 +49,8 @@ class whrandom:
                if 0 == x == y == z:
                        # Initialize from current 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, y = divmod(t, 256)
                        t, z = divmod(t, 256)