This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Mersenne Twister
Type: Stage:
Components: Extension Modules Versions: Python 2.3
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: nnorwitz, rhettinger
Priority: normal Keywords: patch

Created on 2002-12-24 16:45 by rhettinger, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Messages (4)
msg42061 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-12-24 16:45
Alters random.py to easily accept new core 
generators as a superclass.  Added a new class 
WichmannHill for backwards compatibility and to 
serve as a demo of how implement new generators in 
pure python.

Adds _random.c to implement the MersenneTwister 
generator with a 2**19927-1 period, thread-safety, 
and full 53 random bits for each float.

Added test_random.py for non-statistical tests of 
random.py.  If you have any ideas for moving the 
statistical tests, I would love to hear them.

Everything is ready for review and is situated in the 
sandbox under the twister directory.  It includes a 
makefile, setup.py,  a news item, docs and is ready to 
run directly from the sandbox.

Key design decisions needing review:

* getstate() and setstate() now wrap the same 
functions for the core generator so that new 
generators can easily be slipped into place without 
knowing what is going on in random.py and 
random.py's state format can be changed without 
touching the underlying generator.  This decouples 
the two.

* with the new get/set state format, the VERSION 
number was bumped to two.

* I couldn't find a direct analog for jumpahead(n) and 
that may be a problem with other generators too.  
So, I made a weaker implementation that jumps to a 
state far away from the current one.  This means that 
code for the primary use case will still work, but code 
that relies on jumping exact n steps forward will 
break.

* The old WichmannHill code is kept alive in a 
separate subclass.  whseed is now only available 
through that class and is no longer a module level 
attribute.
msg42062 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-12-26 18:11
Logged In: YES 
user_id=33168

Raymond, was there supposed to be a file attached or are we
to review from the sandbox?
msg42063 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-12-26 18:19
Logged In: YES 
user_id=80475

This one is easier to review from the sandbox where all the 
files are in one place and ready to run.

Feel free to directly add tests, edit the docs, improve 
comments, rename variables and whatnot.
msg42064 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-12-29 23:09
Logged In: YES 
user_id=80475

GvR accepted by email.  Thanks to Just van Rossum for 
the initial code review, to Martin v. Löwis for high level 
comments, and to Tim Peters for a thorough code review 
and numerous edits.

Committed as:
Modules/_randommodule.c 1.1
Lib/random.py 1.41
Lib/test/test_random.py 1.3
Doc/lib/librandom.tex 1.33
Misc/NEWS 1.572
setup.py 1.129
History
Date User Action Args
2022-04-10 16:06:03adminsetgithub: 37642
2002-12-24 16:45:57rhettingercreate