[Python-ideas] About adding a new iteratormethodcalled "shuffled"

Jacob Holm jh at improva.dk
Sat Mar 28 01:36:25 CET 2009

Greg Ewing wrote:
> Jacob Holm wrote:
>> Each time I reseed from a truly random source,
> If you have a "truly random source" on hand, then
> you have an infinite amount of entropy available
> and there is no problem. Just feed your truly
> random numbers straight into the shuffling
> algorithm.
Of course.

> We're talking about the case where you *don't*
> have truly random numbers, but only a PRNG with a
> limited amount of internal state.

As it happens, you don't really need the random source.  As long as the 
set of shuffles you can get after reseeding generates the full set of 
permutations, all you need is to reseed in a way that will eventually 
have used all long enough sequences of  possible seed values.

No this is not even remotely practical, and it has very little to do 
with randomness, but I think I said that right from the start.  I was 
just reacting to the statement that you wouldn't be able to generate all 
permutations using shuffle+reseed.  You almost certainly can, but it is 
a silly thing to do.  If you want large random permutations, you need a 
PRNG with an *extremely* long period, and if you have that there is no 
need for repeated shuffles.

- Jacob

More information about the Python-ideas mailing list