From: Guido van Rossum Date: Mon, 16 Feb 1998 14:52:42 +0000 (+0000) Subject: Andrew Kuchling writes: X-Git-Tag: v1.5.1~742 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=358473c1a2a692a496bbbeca330c1e4d52fc78b0;p=thirdparty%2FPython%2Fcpython.git Andrew Kuchling writes: First, the RNG in whrandom.py sucks if you let it seed itself from the time. The problem is the line: t = int((t&0xffffff) | (t>>24)) Since it ORs the two parts together, the resulting value has mostly ON bits. Change | to ^, and you don't lose any randomness. --- diff --git a/Lib/whrandom.py b/Lib/whrandom.py index bd2dcf7befd8..95e88f3399b5 100644 --- a/Lib/whrandom.py +++ b/Lib/whrandom.py @@ -50,7 +50,7 @@ class whrandom: # Initialize from current time import time t = long(time.time() * 256) - t = int((t&0xffffff) | (t>>24)) + t = int((t&0xffffff) ^ (t>>24)) t, x = divmod(t, 256) t, y = divmod(t, 256) t, z = divmod(t, 256)