[Python-checkins] python/dist/src/Doc/lib librandom.tex,1.34,1.35
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Sun Oct 5 05:09:18 EDT 2003
Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv30780/Doc/lib
Modified Files:
librandom.tex
Log Message:
SF bug #812202: randint is always even
* Added C coded getrandbits(k) method that runs in linear time.
* Call the new method from randrange() for ranges >= 2**53.
* Adds a warning for generators not defining getrandbits() whenever they
have a call to randrange() with too large of a population.
Index: librandom.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/librandom.tex,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** librandom.tex 5 Aug 2003 12:23:19 -0000 1.34
--- librandom.tex 5 Oct 2003 09:09:15 -0000 1.35
***************
*** 42,45 ****
--- 42,49 ----
the \method{random()}, \method{seed()}, \method{getstate()},
\method{setstate()} and \method{jumpahead()} methods.
+ Optionally, a new generator can supply a \method{getrandombits()}
+ method --- this allows \method{randrange()} to produce selections
+ over an arbitrarily large range.
+ \versionadded[the \method{getrandombits()} method]{2.4}
As an example of subclassing, the \module{random} module provides
***************
*** 93,96 ****
--- 97,108 ----
\end{funcdesc}
+ \begin{funcdesc}{getrandbits}{k}
+ Returns a python \class{long} int with \var{k} random bits.
+ This method is supplied with the MersenneTwister generator and some
+ other generators may also provide it as an optional part of the API.
+ When available, \method{getrandbits()} enables \method{randrange()}
+ to handle arbitrarily large ranges.
+ \versionadded{2.4}
+ \end{funcdesc}
Functions for integers:
More information about the Python-checkins
mailing list