Random and whrandom

Tim Peters tim.one at home.com
Wed Jan 24 16:02:34 EST 2001


[posted & mailed]

[Alex Martelli, sorts out the random/whrandom mess -- thanks!]
> ...
> The situation might be clearer if Python had MANY random
> number generation modules in its standard library -- one
> as the abstract/high-level thingy, and the other N-1 as
> specific implementations for specific needs.

The "abstract random number generator interface" stuff has been removed from
the 2.1a1 docs.  This is a case where an eager contributor launched into a
Grand Generalization that Guido accepted, then vanished from the face of the
earth immediately thereafter, and nobody else cared enough to take over.
Python's core randomization facilities are too meager to justify all this
conceptual hair, and newbies have been stumbling over the overly-complex
docs ever since ("Define the universe.  Give 3 examples." <wink>).

[kevin parks]
>> It would be great if the random whrandom poop could be cleaned up in
>> future versions of python. One clear module.

[Alex]
> ONE module, I think, would not be enough -- the distinction
> between abstract and concrete IS important enough, after all,
> to be worth a little bit of effort.

It's been counter-productive so far, so got dropped.  "The best" pure-Python
suite of state-of-the-art RNGs is Ivan Frohne's rv.py, and if someone wants
to revive an ARNGI crusade they would do well to mimic his excellent design.
Alas, while it's still possible to find rv's *docs* on the web, I can't find
the actual code anymore (and the Parnassus link is dead).

> ...
> Ideally, too, whrandom should be renamed to _whrandom, the
> leading underline indicating it's meant for internal use
> and not of direct user interest;

We can't, at least not for a few years:  too many programs import it under
the old name.  whrandom's *docs* will get moved into the Obsolete Module
section (where you can also find "rand").

> before this 'deprecation' is done, though, I dearly hope
> checkpoint/restart needs will be considered in the abstract
> RNG interface.

The ARNGI is gone.  Deprecation of whrandom.py is independent of adding C/R
to random.py's bag of tricks.  I agree this would be a good trick to add.

sourceforge-is-open-for-patches-ly y'rs  - tim





More information about the Python-list mailing list