8000 Use random instead of whrandom. · python/cpython@b26a1b4 · GitHub
[go: up one dir, main page]

Skip to content

Commit b26a1b4

Browse files
committed
Use random instead of whrandom.
1 parent 33d7f1a commit b26a1b4

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

Lib/imaplib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Time2Internaldate
1313
"""
1414

15-
import re, socket, string, time, whrandom
15+
import re, socket, string, time, random
1616

1717
# Globals
1818

@@ -109,7 +109,7 @@ def __init__(self, host = '', port = IMAP4_PORT):
109109
# Create unique tag for this session,
110110
# and compile tagged response matcher.
111111

112-
self.tagpre = Int2AP(whrandom.random()*32000)
112+
self.tagpre = Int2AP(random.random()*32000)
113113
self.tagre = re.compile(r'(?P<tag>'
114114
+ self.tagpre
115115
+ r'\d+) (?P<type>[A-Z]+) (?P<data>.*)')

Lib/mimetools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def getsubtype(self):
109109
def choose_boundary():
110110
global _prefix
111111
import time
112-
import whrandom
112+
import random
113113
if _prefix == None:
114114
import socket
115115
import os
@@ -124,7 +124,7 @@ def choose_boundary():
124124
pid = '1'
125125
_prefix = hostid + '.' + uid + '.' + pid
126126
timestamp = '%.3f' % time.time()
127-
seed = `whrandom.randint(0, 32767)`
127+
seed = `random.randint(0, 32767)`
128128
return _prefix + '.' + timestamp + '.' + seed
129129

130130

Lib/test/sortperf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import sys
99
import time
10-
import whrandom
10+
import random
1111
import marshal
1212
import tempfile
1313
import operator
@@ -23,7 +23,7 @@ def randrange(n):
2323
except IOError:
2424
result = []
2525
for i in range(n):
26-
result.append(whrandom.random())
26+
result.append(random.random())
2727
try:
2828
try:
2929
fp = open(fn, "wb")
@@ -44,7 +44,7 @@ def randrange(n):
4444
##assert len(result) == n
4545
# Shuffle it a bit...
4646
for i in range(10):
47-
i = whrandom.randint(0, n-1)
47+
i = random.randint(0, n-1)
4848
temp = result[:i]
4949
del result[:i]
5050
temp.reverse()
@@ -129,7 +129,7 @@ def main():
129129
y = (y^h^d) & 255
130130
h = h>>8
131131
z = (z^h^d) & 255
132-
whrandom.seed(x, y, z)
132+
random.seed(x, y, z)
133133
r = range(k1, k2+1) # include the end point
134134
tabulate(r)
135135

Lib/test/test_thread.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
# Create a bunch of threads, let each do some work, wait until all are done
44

55
from test_support import verbose
6-
import whrandom
6+
import random
77
import thread
88
import time
99

1010
mutex = thread.allocate_lock()
11-
whmutex = thread.allocate_lock() # for calls to whrandom
11+
rmutex = thread.allocate_lock() # for calls to random
1212
running = 0
1313
done = thread.allocate_lock()
1414
done.acquire()
@@ -17,9 +17,9 @@
1717

1818
def task(ident):
1919
global running
20-
whmutex.acquire()
21-
delay = whrandom.random() * numtasks
22-
whmutex.release()
20+
rmutex.acquire()
21+
delay = random.random() * numtasks
22+
rmutex.release()
2323
if verbose:
2424
print 'task', ident, 'will run for', round(delay, 1), 'sec'
2525
time.sleep(delay)
@@ -85,9 +85,9 @@ def task2(ident):
8585
# of the current one
8686
delay = 0.001
8787
else:
88-
whmutex.acquire()
89-
delay = whrandom.random() * numtasks
90-
whmutex.release()
88+
rmutex.acquire()
89+
delay = random.random() * numtasks
90+
rmutex.release()
9191
if verbose:
9292
print 'task', ident, 'will run for', round(delay, 1), 'sec'
9393
time.sleep(delay)

Lib/threading.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ def enumerate():
549549

550550
def _test():
551551

552-
import whrandom
552+
import random
553553

554554
class BoundedQueue(_Verbose):
555555

@@ -592,7 +592,7 @@ def __init__(self, queue, quota):
592592
self.quota = quota
593593

594594
def run(self):
595-
from whrandom import random
595+
from random import random
596596
counter = 0
597597
while counter < self.quota:
598598
counter = counter + 1

0 commit comments

Comments
 (0)
0