random number generator thread safety

Raymond Hettinger python at rcn.com
Tue Nov 8 21:08:05 EST 2005


> > Thread-safety has nothing to do with preserving entropy or guarding
> > against attack.  All of the entropy in an MT sequence is contained in
> > the seed (upto 624 bytes) and that entropy is preserved through all
> > subsequent calls.
>
> I think the concern is that there can be a thread switch after some
> intermediate result is computed but before the state is updated.

The concern expressed by the OP was "preserving entropy or guarding
against attack".

>  That
> would mean two threads can get random numbers that are identical or
> anyway correlated.  Whether that can happen with Python's MT, I don't
> know.

It can't.  That is what the docs mean when they say that MT is
thread-safe.




More information about the Python-list mailing list