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

Andrew Barnert abarnert at yahoo.com
Wed Aug 7 22:57:36 CEST 2013


On Aug 7, 2013, at 12:22, Brandon W Maister <bwmaister at gmail.com> wrote:

> 
>> Andrew Barnert <abarnert at yahoo.com> wrote:
>>> 
>>> But the point is that str.join doesn't use a one-pass algorithm, it just constructs a list so it can do it in two passes. And it's been suggested on this thread that variance could easily do the same thing.
>>> 
>>> .. snip
>>> 
>>> I think you still may be right that the error is the way to go. You'll learn the problem quickly, and the workaround will be obvious, and the reason for it will be available in the docs. The other two potential surprises may not be as discoverable.
> 
> 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.)

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?

> 
> Normally the stdlib accepts iterables anywhere a concrete collection works, but normally also passing in an iterable doesn't change the semantics of a function.
> 
> brandon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130807/24a9271c/attachment-0001.html>


More information about the Python-ideas mailing list