Random and whrandom
Tim Peters
tim.one at home.com
Wed Jan 24 22:50:28 EST 2001
[posted & mailed]
[Alex Martelli]
> ...
> before this 'deprecation' is done, though, I dearly hope
> checkpoint/restart needs will be considered in the abstract
> RNG interface.
FYI, I just checked in changes to random.py to supply getstate()/setstate()
methods. While it wasn't documented, it turns out that-- via reliable
accident --you could checkpoint/restart the old whrandom just by pickling
and unpickling its hidden "_inst" vrbl. Wasn't enough for random.py,
though, as that was also hiding state in module globals. The reworked
random.py makes everything a method of a new (but usually invisible) Random
class, and its getstate()/setstate() methods save/restore all the state
(&also arranges for pickles to work reliably too).
yet-another-reason-to-hunger-for-2.1a2-ly y'rs - tim
More information about the Python-list
mailing list