[Python-checkins] python/dist/src/Doc/lib librandom.tex,1.35,1.36
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Mon Aug 30 08:14:43 CEST 2004
Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26687/Doc/lib
Modified Files:
librandom.tex
Log Message:
Teach the random module about os.urandom().
* Use it for seeding when it is available.
* Provide an alternate generator based on it.
Index: librandom.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/librandom.tex,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- librandom.tex 5 Oct 2003 09:09:15 -0000 1.35
+++ librandom.tex 30 Aug 2004 06:14:31 -0000 1.36
@@ -61,7 +61,10 @@
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 @@
\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 @@
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
More information about the Python-checkins
mailing list