From d3aa5d2c5cd848d0ea6ec631a57f44d9d533fe7f Mon Sep 17 00:00:00 2001 From: David Rideout <37720241+d-rideout@users.noreply.github.com> Date: Mon, 28 Aug 2023 18:26:27 -0700 Subject: [PATCH] clarify limit on length of sequences which can be shuffle()d Fixes [Issue #108598](https://github.com/python/cpython/issues/108598) --- Doc/library/random.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/library/random.rst b/Doc/library/random.rst index 76ae97a8be7e63..9cc77b3a32a278 100644 --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -214,11 +214,11 @@ Functions for sequences To shuffle an immutable sequence and return a new shuffled list, use ``sample(x, k=len(x))`` instead. - Note that even for small ``len(x)``, the total number of permutations of *x* - can quickly grow larger than the period of most random number generators. - This implies that most permutations of a long sequence can never be - generated. For example, a sequence of length 2080 is the largest that - can fit within the period of the Mersenne Twister random number generator. + Note that the total number of permutations of *x* grows rapidly with its length, + such that the number of permutations can easily exceed the number of internal states of + a pseudo random number generator. This implies that most permutations of a long sequence + can never be generated. For example, a sequence of length greater than 2080 can not + be sampled uniformly by the Mersenne Twister random number generator. .. deprecated-removed:: 3.9 3.11 The optional parameter *random*.