[Python-Dev] a note in random.shuffle.__doc__ ...

Alex Martelli aleaxit at gmail.com
Sat Jun 10 21:04:23 CEST 2006


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!


More information about the Python-Dev mailing list