[Python-ideas] statistics.sum [was Re: Pre-PEP: adding a statistics module to Python]

David Mertz mertz at gnosis.cx
Mon Aug 5 22:43:44 CEST 2013


On Mon, Aug 5, 2013 at 1:04 PM, Steven D'Aprano <steve at pearwood.info> wrote:

> * One Obvious Way / Only One Way -- there are already two ways to
> calculate a sum (builtins.sum and math.fsum), no need for a third.
> * Even if we can't, don't call it "sum", call it something else.
> "precise_sum" was the only suggestion given so far.
>

I think I am probably +1 on statistics.sum().  Actually, I think it should
be called math.statistics.sum(), but that's a smaller issue.

However, one name that hasn't been mentioned might be even better:
statistics._sum().  You need it within the module, it needs behavior that
isn't quite the same as either builtins.sum() nor as math.fsum() (though it
may utilize those internally).  Calling it by such a "private" name seems
to concord pretty well with Python naming conventions.  Moreover, someone
other than the module author CAN use it if they want to.


-- 
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130805/a089c74d/attachment.html>


More information about the Python-ideas mailing list