[Python-ideas] Pre-PEP: adding a statistics module to Python

Brandon W Maister bwmaister at gmail.com
Thu Aug 8 00:08:48 CEST 2013


On Wed, Aug 7, 2013 at 4:57 PM, Andrew Barnert <abarnert at yahoo.com> wrote:

> On Aug 7, 2013, at 12:22, Brandon W Maister <bwmaister at gmail.com> wrote:
>
> I agree that the error is the way to go, but what about
> `variance(iterable, one_pass=True)` defaulting to False, with an exception
> that says "Warning: passing an iterable and using the one pass algorithm
> can lead to a slight loss in accuracy" if an iterable is passed in?
>
>
> First, I think you meant "iterator" there, not "iterable". (A list is an
> iterable, but not an iterator.)
>

Oops, you're completely correct.

Second, I'd expect that onepass=True would lead to a loss in accuracy no
> matter what the other argument was.
>
> Finally, if passing onepass=True causes it to raise an exception, why even
> have the option?
>

Sorry, I was unclear: I should have written something more like
`allow_one_pass=True` and defaulting to False. Passing in True would
silence the error, and force users to mean what they say.

I don't feel strongly that it's a _good_ idea: I have never written code
that would need to take advantage of a one pass algorithm, and I have no
idea how common such code would be. If someone is at the point where
they're trying to optimize their variance function they are probably at the
point where they're moving beyond the stdlib anyway?

brandon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130807/06063926/attachment.html>


More information about the Python-ideas mailing list