[Python-ideas] Yet another sum function (fractions.sum)
Clay Sweetser
clay.sweetser at gmail.com
Mon Aug 19 15:47:31 CEST 2013
On Aug 19, 2013 6:09 AM, "Peter Otten" <__peter__ at web.de> wrote:
>
> If that takes on, and the number of sum implementations grows, maybe there
> should be a __sum__() special (class) method, and the sum built-in be
> changed roughly to
>
> def sum(items, start=0):
> try:
> specialized_sum = start.__sum__
> except AttributeError:
> return ... # current behaviour
> return specialized_sum(items, start)
>
> sum(items, 0.0) would then automatically profit from the clever
> optimizations of math.fsum() etc.
Another possibility (and I'm not suggesting that it's better than the
proposed solution above) is to make a module just for the numerous sum
implementations people need.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130819/4f08cc22/attachment.html>
More information about the Python-ideas
mailing list