C API for Python's RNG?

Tom Loredo loredo at astro.cornell.edu
Fri Jun 28 15:38:34 EDT 2002


Hi folks-

I'm doing some Monte Carlo calculations, and to speed things up
I'm dumping parts of it into an extension.  I'll be needing random
numbers both in the Python code and in the extension.  I'd like
to use Python's RNG in the extension so I can easily maintain
the state of the whole calculation if necessary.  So I need to
know the C API for Python's RNG.  I don't see it documented in the
standard documentation.  I'll dig in the source to try to puzzle
it out, but I thought I should ask publicly:  is this documented
anywhere?  If not, is there anything I should be careful about
that may not be obvious?  How stable is the API from version
to version of Python?

I suppose I could switch to the Numeric Random module, but the
C API for that isn't documented either, so I have the same questions
about that.

Thanks,
Tom Loredo



More information about the Python-list mailing list