I think for multiple streams it's best to make your own instances of random.Random. Most of the functions that the random module exposes are just methods of a single global random function, see the source here:
https://hg.python.org/cpython/file/2.7/Lib/random.py#l885
Cheers,
Carl Friedrich
Matti,On 7 Mar 2015, at 19:37, Matti Picus <matti.picus@gmail.com> wrote:
'''
jumpahead(self, n) method of random.Random instance
Change the internal state to one that is likely far away
from the current state. This method will not be in Py3.x,
so it is better to simply reseed.
'''Thanks for pointing out.I'm using the jumpahead() to have multiple streams in parallel, derived from a single point.def jumpRandomState(self):
self.random.setstate(self.randomState)
self.random.jumpahead(1)
self.randomState = self.random.getstate()Would this be a good alternative?def jumpRandomState(self):
self.random.setstate(self.randomState)
self.random.seed(self.random.random())
self.randomState = self.random.getstate().Floris
pypy-dev mailing list
pypy-dev@python.org
https://mail.python.org/mailman/listinfo/pypy-dev