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.
diff --git a/Doc/lib/librandom.tex b/Doc/lib/librandom.tex
index 5483ff2..2b686ec 100644
--- a/Doc/lib/librandom.tex
+++ b/Doc/lib/librandom.tex
@@ -41,6 +41,10 @@
different basic generator of your own devising: in that case, override
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
the \class{WichmannHill} class which implements an alternative generator
@@ -92,6 +96,14 @@
separated by many steps.]{2.3}
\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: