[Python-ideas] New function to add into the "random" module

Paul Moore p.f.moore at gmail.com
Thu Feb 2 09:43:44 EST 2017


On 2 February 2017 at 12:01, <himchanterry at gmail.com> wrote:

> P.P.S.: The function is tested, it’s working 😊
>

First of all, thanks for your suggestion, and for taking the time to help
improve Python. As noted, random.uniform probably does what you want, so we
don't really need this function.

But in case it's of interest to you, there's some additional considerations
around proposed additions to the stdlib that we'd normally look at with a
suggestion like this. If you find any other improvements you'd be
interested in proposing, it might be helpful to you to be aware of them.

The first thing that struck me was the performance of your approach. With
multiple number<->string conversions it is likely to be extremely slow,
making this function completely unsuitable for things like simulations,
where the ability to generate many millions of results fast is critical.
Python stdlib functions typically get used in a wide range of situations,
and we need to make sure they are suitable for as large a range of
applications as we can.

Also, I'd be curious to know how you tested your function. Random number
generators are notoriously difficult to get right, and you are here
combining the results of multiple calls to the underlying PRNG. By doing
so, you might (as far as I know, it's unlikely, but it's possible) have
degraded the randomness of the result. Did your function pass the standard
tests for randomness? Note: I don't know what those tests are, but I do
know that such things exist, and I'd expect anything in the stdlib to have
been validated by people who *do* know such things. Again, stdlib functions
get used in a wide range of applications, and the authors typically rely on
the Python developers to have "got the details right" on their behalf.

Anyway, these are just a couple of thoughts for you. I hope they were of
interest, and thanks again for contributing.

Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170202/28dafa7b/attachment.html>


More information about the Python-ideas mailing list