Implementaion of random.shuffle

Hrvoje Niksic hniksic at xemacs.org
Tue Jul 17 04:47:49 EDT 2007


Steven D'Aprano <steven at REMOVE.THIS.cybersource.com.au> writes:

> In the case of CPython, the current implementation uses the Mersenne
> Twister, which has a huge period of 2**19937. However, 2081! is
> larger than that number, which means that at best a list of 2081
> items or longer can't be perfectly shuffled (not every permutation
> can be selected by the algorithm).

Note that each shuffle requires n calls to the PRNG, not just one,
which reduces the theoretically safe list size by 1.



More information about the Python-list mailing list