8000 gh-108598: clarify limit on length of sequences which can be shuffle()d by d-rideout · Pull Request #108610 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-108598: clarify limit on length of sequences which can be shuffle()d #108610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Doc/library/random.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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*.
Expand Down
0