SHA-based subclass for random module

Raymond Hettinger python at rcn.com
Wed Mar 24 04:24:53 EST 2004


[Trevor Perrin] 
> I'm proposing that getrandstring() (returning a string) is a better 
> primitive than getrandbits() (returning a long). 
<snip>
> This would be easy to implement with Mersenne Twister too.  Though it 
> would involve some rewriting.
> 
> Do you think this is worthwhile?

Sorry, I do not think that introducing a string method into an
otherwise numeric module would make it easier to use.

The is doubly true because the API also requires that new generators
implement random(), returning a float, which means that you have to
convert to a number at some point anyway.

What might be nice is if longs had methods for converting to and from
bytestrings.  Currently, the knowledge for how to do that is
sequestered in the pickle module.


Raymond



More information about the Python-list mailing list