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
d0946da7
Commit
d0946da7
authored
Feb 01, 2001
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some markup breakage that prevented formatting; re-wrapped a couple of
wide paragraphs.
parent
c2e35e6f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
Doc/lib/librandom.tex
Doc/lib/librandom.tex
+10
-10
No files found.
Doc/lib/librandom.tex
View file @
d0946da7
...
...
@@ -70,16 +70,16 @@ def create_generators(num, delta, firstseed=None):
gens = create
_
generators(10, 1000000)
\end{verbatim}
That creates 10 distinct generators, which can be passed out to 10
distinct
threads. The generators don't share state so can be called safely in
parallel. So long as no thread calls its
\code
{
g.random()
}
more than a
m
illion times (the second argument to
\function
{
create
_
generators), the
sequences seen by each thread will not overlap. The period of the
underlying Wichmann-Hill generator limits how far this technique can be
pushed.
That creates 10 distinct generators, which can be passed out to 10
distinct threads. The generators don't share state so can be called
safely in parallel. So long as no thread calls its
\code
{
g.random()
}
m
ore than a million times (the second argument to
\function
{
create
_
generators()
}
, the sequences seen by each thread will
not overlap. The period of the underlying Wichmann-Hill generator
limits how far this technique can be
pushed.
Just for fun, note that since we know the period,
\method
{
jumpahead()
}
can
also be used to "move backward in time":
Just for fun, note that since we know the period,
\method
{
jumpahead()
}
can also be used to ``move backward in time:''
\begin{verbatim}
>>> g = Random(42) # arbitrary
...
...
@@ -100,7 +100,7 @@ Bookkeeping functions:
current system time is also used to initialize the generator when the
module is first imported.
If
\var
(x) is not
\code
{
None
}
or an int or long,
\code
{
hash(
\var
{
x
}
)
)
is used instead.
\code
{
hash(
\var
{
x
}
)
}
is used instead.
If
\var
{
x
}
is an int or long,
\var
{
x
}
is used directly.
Distinct values between 0 and 27814431486575L inclusive are guaranteed
to yield distinct internal states (this guarantee is specific to the
...
...
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