numpy/numpy — pull request #4609 by juliantaylor (2014-04-10 23:35:00+00:00)
Title: ENH: replace GIL of random module with a per state lock

The random module currently relies on the GIL for the state
synchronization which hampers threading performance.
Instead add a lock to the RandomState module and take it for all
operations calling into randomkit while releasing the GIL.
This allows parallizing random number generation using multiple states
or asynchronous generation in a worker thread.

Note that with a large number of threads the standard mersenne twister
used may exhibit overlap if the number of parallel streams is large
compared to the size of the state space, though due to the limited
scalability of Python in regards to threads this is likely not a big
issue.