Unsorting(randomizing) a sequence

Stephan Houben stephan at pcrm.win.tue.nl
Mon Aug 23 03:03:22 EDT 1999


"Tim Peters" <tim_one at email.msn.com> writes:

> [Tim, on the difficulty of generating random permutations, because
>  n! quickly grows larger than a given random-# generator's period]
> 
> [Aahz Maruch]
> > What happens if you re-seed?
> 
> By what means?  If you have a good source of random bits to do the reseeding
> with, save yourself the expense of calling random() and just use them
> directly <0.1 wink>. 

Actually, on Linux you could reseed by reading values from /dev/random.
/dev/random will block if not enough "random" events are happening
in the system to satisfy your application's hunger for random number.
So this might actually make a little sense; a *real* random source
(like /dev/random supposedly is) might be too slow to produce
enough numbers.

...although there is also /dev/urandom, which basically solves this
problem for you (i.e. it uses the same mechanism as /dev/random to create
random numbers, until the kernel is out of random numbers, and then
it continues with pseudorandom numbers).

Greetings,

Stephan




More information about the Python-list mailing list