Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
294ea161
Commit
294ea161
authored
May 20, 1998
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use random instead of whrandom.
parent
a96ea079
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
18 deletions
+18
-18
Lib/imaplib.py
Lib/imaplib.py
+2
-2
Lib/mimetools.py
Lib/mimetools.py
+2
-2
Lib/test/sortperf.py
Lib/test/sortperf.py
+4
-4
Lib/test/test_thread.py
Lib/test/test_thread.py
+8
-8
Lib/threading.py
Lib/threading.py
+2
-2
No files found.
Lib/imaplib.py
View file @
294ea161
...
@@ -12,7 +12,7 @@ Public functions: Internaldate2tuple
...
@@ -12,7 +12,7 @@ Public functions: Internaldate2tuple
Time2Internaldate
Time2Internaldate
"""
"""
import
re
,
socket
,
string
,
time
,
wh
random
import
re
,
socket
,
string
,
time
,
random
# Globals
# Globals
...
@@ -109,7 +109,7 @@ class IMAP4:
...
@@ -109,7 +109,7 @@ class IMAP4:
# Create unique tag for this session,
# Create unique tag for this session,
# and compile tagged response matcher.
# and compile tagged response matcher.
self.tagpre = Int2AP(
wh
random.random()*32000)
self.tagpre = Int2AP(random.random()*32000)
self.tagre = re.compile(r'(?P<tag>'
self.tagre = re.compile(r'(?P<tag>'
+ self.tagpre
+ self.tagpre
+ r'
\
d+) (?P<
t
ype>[A-Z]+) (?P<data>.*)')
+ r'
\
d+) (?P<
t
ype>[A-Z]+) (?P<data>.*)')
...
...
Lib/mimetools.py
View file @
294ea161
...
@@ -109,7 +109,7 @@ _prefix = None
...
@@ -109,7 +109,7 @@ _prefix = None
def
choose_boundary
():
def
choose_boundary
():
global
_prefix
global
_prefix
import
time
import
time
import
wh
random
import
random
if
_prefix
==
None
:
if
_prefix
==
None
:
import
socket
import
socket
import
os
import
os
...
@@ -124,7 +124,7 @@ def choose_boundary():
...
@@ -124,7 +124,7 @@ def choose_boundary():
pid
=
'1'
pid
=
'1'
_prefix
=
hostid
+
'.'
+
uid
+
'.'
+
pid
_prefix
=
hostid
+
'.'
+
uid
+
'.'
+
pid
timestamp
=
'%.3f'
%
time
.
time
()
timestamp
=
'%.3f'
%
time
.
time
()
seed
=
`
wh
random.randint(0, 32767)`
seed
=
`random.randint(0, 32767)`
return
_prefix
+
'.'
+
timestamp
+
'.'
+
seed
return
_prefix
+
'.'
+
timestamp
+
'.'
+
seed
...
...
Lib/test/sortperf.py
View file @
294ea161
...
@@ -7,7 +7,7 @@ See tabulate() for output format.
...
@@ -7,7 +7,7 @@ See tabulate() for output format.
import
sys
import
sys
import
time
import
time
import
wh
random
import
random
import
marshal
import
marshal
import
tempfile
import
tempfile
import
operator
import
operator
...
@@ -23,7 +23,7 @@ def randrange(n):
...
@@ -23,7 +23,7 @@ def randrange(n):
except
IOError
:
except
IOError
:
result
=
[]
result
=
[]
for
i
in
range
(
n
):
for
i
in
range
(
n
):
result
.
append
(
wh
random
.
random
())
result
.
append
(
random
.
random
())
try
:
try
:
try
:
try
:
fp
=
open
(
fn
,
"wb"
)
fp
=
open
(
fn
,
"wb"
)
...
@@ -44,7 +44,7 @@ def randrange(n):
...
@@ -44,7 +44,7 @@ def randrange(n):
##assert len(result) == n
##assert len(result) == n
# Shuffle it a bit...
# Shuffle it a bit...
for
i
in
range
(
10
):
for
i
in
range
(
10
):
i
=
wh
random
.
randint
(
0
,
n
-
1
)
i
=
random
.
randint
(
0
,
n
-
1
)
temp
=
result
[:
i
]
temp
=
result
[:
i
]
del
result
[:
i
]
del
result
[:
i
]
temp
.
reverse
()
temp
.
reverse
()
...
@@ -129,7 +129,7 @@ def main():
...
@@ -129,7 +129,7 @@ def main():
y
=
(
y
^
h
^
d
)
&
255
y
=
(
y
^
h
^
d
)
&
255
h
=
h
>>
8
h
=
h
>>
8
z
=
(
z
^
h
^
d
)
&
255
z
=
(
z
^
h
^
d
)
&
255
wh
random
.
seed
(
x
,
y
,
z
)
random
.
seed
(
x
,
y
,
z
)
r
=
range
(
k1
,
k2
+
1
)
# include the end point
r
=
range
(
k1
,
k2
+
1
)
# include the end point
tabulate
(
r
)
tabulate
(
r
)
...
...
Lib/test/test_thread.py
View file @
294ea161
...
@@ -3,12 +3,12 @@
...
@@ -3,12 +3,12 @@
# Create a bunch of threads, let each do some work, wait until all are done
# Create a bunch of threads, let each do some work, wait until all are done
from
test_support
import
verbose
from
test_support
import
verbose
import
wh
random
import
random
import
thread
import
thread
import
time
import
time
mutex
=
thread
.
allocate_lock
()
mutex
=
thread
.
allocate_lock
()
whmutex
=
thread
.
allocate_lock
()
# for calls to wh
random
rmutex
=
thread
.
allocate_lock
()
# for calls to
random
running
=
0
running
=
0
done
=
thread
.
allocate_lock
()
done
=
thread
.
allocate_lock
()
done
.
acquire
()
done
.
acquire
()
...
@@ -17,9 +17,9 @@ numtasks = 10
...
@@ -17,9 +17,9 @@ numtasks = 10
def
task
(
ident
):
def
task
(
ident
):
global
running
global
running
wh
mutex
.
acquire
()
r
mutex
.
acquire
()
delay
=
wh
random
.
random
()
*
numtasks
delay
=
random
.
random
()
*
numtasks
wh
mutex
.
release
()
r
mutex
.
release
()
if
verbose
:
if
verbose
:
print
'task'
,
ident
,
'will run for'
,
round
(
delay
,
1
),
'sec'
print
'task'
,
ident
,
'will run for'
,
round
(
delay
,
1
),
'sec'
time
.
sleep
(
delay
)
time
.
sleep
(
delay
)
...
@@ -85,9 +85,9 @@ def task2(ident):
...
@@ -85,9 +85,9 @@ def task2(ident):
# of the current one
# of the current one
delay
=
0.001
delay
=
0.001
else
:
else
:
wh
mutex
.
acquire
()
r
mutex
.
acquire
()
delay
=
wh
random
.
random
()
*
numtasks
delay
=
random
.
random
()
*
numtasks
wh
mutex
.
release
()
r
mutex
.
release
()
if
verbose
:
if
verbose
:
print
'task'
,
ident
,
'will run for'
,
round
(
delay
,
1
),
'sec'
print
'task'
,
ident
,
'will run for'
,
round
(
delay
,
1
),
'sec'
time
.
sleep
(
delay
)
time
.
sleep
(
delay
)
...
...
Lib/threading.py
View file @
294ea161
...
@@ -549,7 +549,7 @@ _MainThread()
...
@@ -549,7 +549,7 @@ _MainThread()
def
_test
():
def
_test
():
import
wh
random
import
random
class
BoundedQueue
(
_Verbose
):
class
BoundedQueue
(
_Verbose
):
...
@@ -592,7 +592,7 @@ def _test():
...
@@ -592,7 +592,7 @@ def _test():
self
.
quota
=
quota
self
.
quota
=
quota
def
run
(
self
):
def
run
(
self
):
from
wh
random
import
random
from
random
import
random
counter
=
0
counter
=
0
while
counter
<
self
.
quota
:
while
counter
<
self
.
quota
:
counter
=
counter
+
1
counter
=
counter
+
1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment