Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7955653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:45:45+00:00 2026-06-04T03:45:45+00:00

From the Python documentation for random.shuffle, which takes a list and randomizes the order

  • 0

From the Python documentation for random.shuffle, which takes a list and randomizes the order if its elements:

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.

Is this true of any language, since the limitation seems dependent on the random number generator? Is it possible to write a function that can generate any possible permutation of an arbitrarily long list?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:45:46+00:00Added an answer on June 4, 2026 at 3:45 am

    See http://mail.python.org/pipermail/python-ideas/2009-March/003670.html . The exact length that it starts being a problem at is dependent on the PRNG, but the basic problem will always apply.

    The previous question that @TryPyPy linked to is also focused on Python, but the accepted answer explains quite well why it will always happen. To paraphrase, you can imagine a naive shuffle algorithm working this way:

    1. Generate a list, p, of all possible permutations of the input
    2. Get a random number, x, from your PRNG
    3. The shuffled list is p[x]

    If p is longer than the list of all possible xs that the PRNG can produce, some of the permutations are unreachable.

    Since fancy shuffle algorithms are, at their core, a way of doing this without having to generate every possible permutation before discarding all but one of them, the only way around this is to have a source of true randomness.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Python documentation says that sys.path is Initialized from the environment variable PYTHONPATH ,
I've run into some behavior from Python 2.6.1 that I didn't expect. Here is
I have developed a python C-extension that receives data from python and compute some
The Python documentation for except says: For an except clause with an expression, that
This is a simple example from the python documentation (http://docs.python.org/extending/extending.html): static PyObject * spam_system(PyObject
I have had the following problem which both Google and the Python documentation cannot
Sorry, but I can't figure this out from the Python documentation or any of
Python documentation from http://docs.python.org/library/string.html : string.lstrip(s[, chars]) Return a copy of the string with
What exactly do *args and **kwargs mean? According to the Python documentation, from what
The python documentation on array clearly states that the array conforms to the buffer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.