]> granicus.if.org Git - python/commitdiff
Use random instead of whrandom.
authorGuido van Rossum <guido@python.org>
Wed, 20 May 1998 17:05:52 +0000 (17:05 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 20 May 1998 17:05:52 +0000 (17:05 +0000)
Lib/imaplib.py
Lib/mimetools.py
Lib/test/sortperf.py
Lib/test/test_thread.py
Lib/threading.py

index 3c45b2e48c57897e6f9aac684015be38df046a21..28f62f4fa002a48ff1eb759fe22c532661af93cf 100644 (file)
@@ -12,7 +12,7 @@ Public functions:     Internaldate2tuple
                        Time2Internaldate
 """
 
-import re, socket, string, time, whrandom
+import re, socket, string, time, random
 
 #      Globals
 
@@ -109,7 +109,7 @@ class IMAP4:
                # Create unique tag for this session,
                # and compile tagged response matcher.
 
-               self.tagpre = Int2AP(whrandom.random()*32000)
+               self.tagpre = Int2AP(random.random()*32000)
                self.tagre = re.compile(r'(?P<tag>'
                                + self.tagpre
                                + r'\d+) (?P<type>[A-Z]+) (?P<data>.*)')
index eed24ca0af1710a719cb915e325d8fdd6d8c3f8d..fc72c79ed3acef3e19704220b8a9b64730fd1133 100644 (file)
@@ -109,7 +109,7 @@ _prefix = None
 def choose_boundary():
        global _prefix
        import time
-       import whrandom
+       import random
        if _prefix == None:
                import socket
                import os
@@ -124,7 +124,7 @@ def choose_boundary():
                    pid = '1'
                _prefix = hostid + '.' + uid + '.' + pid
        timestamp = '%.3f' % time.time()
-       seed = `whrandom.randint(0, 32767)`
+       seed = `random.randint(0, 32767)`
        return _prefix + '.' + timestamp + '.' + seed
 
 
index 8355f7ada75c466cb9a473bfaf4de2c18b67c1e8..58fd8a70285c5d4b447e820e7b26b731eb9bb200 100644 (file)
@@ -7,7 +7,7 @@ See tabulate() for output format.
 
 import sys
 import time
-import whrandom
+import random
 import marshal
 import tempfile
 import operator
@@ -23,7 +23,7 @@ def randrange(n):
     except IOError:
         result = []
         for i in range(n):
-            result.append(whrandom.random())
+            result.append(random.random())
         try:
             try:
                 fp = open(fn, "wb")
@@ -44,7 +44,7 @@ def randrange(n):
         ##assert len(result) == n
         # Shuffle it a bit...
         for i in range(10):
-            i = whrandom.randint(0, n-1)
+            i = random.randint(0, n-1)
             temp = result[:i]
             del result[:i]
             temp.reverse()
@@ -129,7 +129,7 @@ def main():
                     y = (y^h^d) & 255
                     h = h>>8
                     z = (z^h^d) & 255
-                whrandom.seed(x, y, z)
+                random.seed(x, y, z)
     r = range(k1, k2+1)                 # include the end point
     tabulate(r)
 
index 113135bef9d0f4de463f419667e9125875aae1f4..710fb89430edd95c8bb607790499e3a0a9688339 100644 (file)
@@ -3,12 +3,12 @@
 # Create a bunch of threads, let each do some work, wait until all are done
 
 from test_support import verbose
-import whrandom
+import random
 import thread
 import time
 
 mutex = thread.allocate_lock()
-whmutex = thread.allocate_lock() # for calls to whrandom
+rmutex = thread.allocate_lock() # for calls to random
 running = 0
 done = thread.allocate_lock()
 done.acquire()
@@ -17,9 +17,9 @@ numtasks = 10
 
 def task(ident):
        global running
-       whmutex.acquire()
-       delay = whrandom.random() * numtasks
-       whmutex.release()
+       rmutex.acquire()
+       delay = random.random() * numtasks
+       rmutex.release()
        if verbose:
            print 'task', ident, 'will run for', round(delay, 1), 'sec'
        time.sleep(delay)
@@ -85,9 +85,9 @@ def task2(ident):
                        # of the current one
                        delay = 0.001
                else:
-                       whmutex.acquire()
-                       delay = whrandom.random() * numtasks
-                       whmutex.release()
+                       rmutex.acquire()
+                       delay = random.random() * numtasks
+                       rmutex.release()
                if verbose:
                    print 'task', ident, 'will run for', round(delay, 1), 'sec'
                time.sleep(delay)
index 79319c1d7ea00c835d330b68f8047543170263c8..d2ab9ed2f5d4a4e5b7df023535d1fddc8ab36bcd 100644 (file)
@@ -549,7 +549,7 @@ _MainThread()
 
 def _test():
 
-    import whrandom
+    import random
 
     class BoundedQueue(_Verbose):
 
@@ -592,7 +592,7 @@ def _test():
             self.quota = quota
 
         def run(self):
-            from whrandom import random
+            from random import random
             counter = 0
             while counter < self.quota:
                 counter = counter + 1