Pure python implementation of Mersenne Twister?

Sean 'Shaleh' Perry shalehperry at attbi.com
Tue Oct 29 17:25:05 CET 2002


On Tuesday 29 October 2002 07:25, PoulsenL at capanalysis.com wrote:
> I know of at least 3 implementations of the Mersenne Twister algorithm as C
> extensions for python, but has anyone written one in pure python, for
> educational purposes, for example?
>
> Thanks in advance,
>
> Loren

so I hit google, found the mersenne home page, grabbed a C source and 
transliterated it to python.  The two output identical results so i have some 
faith in the translation.  Took me about 15 minutes, testing and all.

Attached is the .py and the original .c.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mersenne.py
Type: text/x-python
Size: 3745 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20021029/125e5f3a/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mersenne.c
Type: text/x-csrc
Size: 4291 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20021029/125e5f3a/attachment.c>


More information about the Python-list mailing list