summaryrefslogtreecommitdiffstats
path: root/Doc/lib/librandom.tex
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-08-30 06:14:31 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-08-30 06:14:31 (GMT)
commit356a4599acd4c835ab88c221bd5da073c9895e83 (patch)
tree3929bfcd683de30940287e26e7d213bf74fb8db4 /Doc/lib/librandom.tex
parentcd97da3b1d61be00bb06f3264a60418dbdb83bd8 (diff)
downloadcpython-356a4599acd4c835ab88c221bd5da073c9895e83.zip
cpython-356a4599acd4c835ab88c221bd5da073c9895e83.tar.gz
cpython-356a4599acd4c835ab88c221bd5da073c9895e83.tar.bz2
Teach the random module about os.urandom().
* Use it for seeding when it is available. * Provide an alternate generator based on it.
Diffstat (limited to 'Doc/lib/librandom.tex')
-rw-r--r--Doc/lib/librandom.tex18
1 files changed, 16 insertions, 2 deletions
diff --git a/Doc/lib/librandom.tex b/Doc/lib/librandom.tex
index 2b686ec..787e134 100644
--- a/Doc/lib/librandom.tex
+++ b/Doc/lib/librandom.tex
@@ -61,7 +61,10 @@ Bookkeeping functions:
Optional argument \var{x} can be any hashable object.
If \var{x} is omitted or \code{None}, current system time is used;
current system time is also used to initialize the generator when the
- module is first imported.
+ module is first imported. If hardware random sources are available,
+ they are used instead of the system time (see the \function{os.urandom()}
+ function for details on availability). \versionchanged[formerly,
+ hardward sources were not used]{2.4}
If \var{x} is not \code{None} or an int or long,
\code{hash(\var{x})} is used instead.
If \var{x} is an int or long, \var{x} is used directly.
@@ -227,7 +230,7 @@ these equations can be found in any statistics text.
\var{beta} is the shape parameter.
\end{funcdesc}
-Alternative Generator
+Alternative Generators
\begin{classdesc}{WichmannHill}{\optional{seed}}
Class that implements the Wichmann-Hill algorithm as the core generator.
@@ -246,6 +249,17 @@ require care that two independent random sequences do not overlap.
yield no more than about 2**24 distinct internal states in all.
\end{funcdesc}
+\begin{classdesc}{HardwareRandom}{\optional{seed}}
+Class that uses the \function{os.urandom()} function for generating
+random numbers from hardware. Not available on all systems.
+Does not rely on software state and sequences are not reproducible.
+Accordingly, the \method{seed()} and \method{jumpahead()} methods
+have no effect and are ignored. The \method{getstate()} and
+\method{setstate()} methods raise \exception{NotImplementedError} if
+called.
+\versionadded{2.4}
+\end{classdesc}
+
\begin{seealso}
\seetext{M. Matsumoto and T. Nishimura, ``Mersenne Twister: A
623-dimensionally equidistributed uniform pseudorandom