[Python-Dev] a note in random.shuffle.__doc__ ...
rhettinger at ewtllc.com
Mon Jun 12 15:52:18 CEST 2006
Alex Martelli wrote:
>Note that for even rather small len(x), the total number of
>permutations of x is larger than the period of most random number
>generators; this implies that "most" permutations of a long
>sequence can never be generated.
>Now -- why would the behavior of "most" random number generators be
>relevant here? The module's docs claim, for its specific Mersenne
>Twister generator, a period of 2**19997-1, which is (e.g.) a
>859403269022650639413550466514556014961826309062543 times larger than
>the number of permutations of 2000 items, which doesn't really feel
>to me like a "rather small len(x)" in this context (what I'm most
>often shuffling is just a pack of cards -- len(x)==52 -- for example).
>I suspect that the note is just a fossil from a time when the default
>random number generator was Whichman-Hill, with a much shorter
>period. Should this note just be removed, or instead somehow
>reworded to point out that this is not in fact a problem for the
>module's current default random number generator? Opinions welcome!
I think the note is still useful, but the "rather small" wording
should be replaced by something most precise (such as the
value of n=len(x) where n! > 2**19997).
More information about the Python-Dev