Oscar Benjamin added the comment:
I should be clearer about my intentions. I'm hoping to create an
efficient and accurate sum() function for the new stdlib statistics
module:
http://bugs.python.org/issue18606
http://www.python.org/dev/peps/pep-0450/
The sum() function currently proposed can be
Tim Peters added the comment:
The possible use cases are so varied fuzzy it seems better to use an object
for this, rather than funk-ify `fsum`. Say, class Summer. Then methods could
be invented as needed, with whatever state is required belonging to Summer
objects rather than passed
Raymond Hettinger added the comment:
Let's close this one. As Uncle Timmy says, it would be a mistake to funkify
the signature for math.fsum.
If something like a Summer() class is born, it should start it life outside the
standard library, gain a following, and let both the API and
Oscar Benjamin added the comment:
Fair enough.
Thanks again for taking the time to look at this.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19086
___
Raymond Hettinger added the comment:
Conceptually, I support the idea of having some way to avoid information loss
by returning uncollapsed partial sums. As you say, it would provide an
essential primitive for parallel fsums and for cumulative subtotals.
If something along those lines were
Oscar Benjamin added the comment:
Thanks for responding Raymond.
Raymond Hettinger wrote:
A start argument won't help you, because you will discard information
on input. A sequence like [1E100, 0.1, -1E100, 0.1] wouldn't work when
split into subtotal=fsum([1E100, 0.1]) and fsum([-1E100, 0.1],
Changes by Raymond Hettinger raymond.hettin...@gmail.com:
--
assignee: - rhettinger
priority: normal - low
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19086
___
Raymond Hettinger added the comment:
FWIW, the reason for __builtin__.sum() having a start argument was so that it
could change the base datatype: sum(iterable, start=Fraction(0)).
[Oscar Benjamin]
Although fsum is internally very accurate
it always discards information on output.
A
New submission from Oscar Benjamin:
I would like to be able use fsum incrementally however it is not currently
possible.
With sum() you can do:
subtotal = sum(nums)
subtotal = sum(othernums, subtotal)
This wouldn't work for fsum() because the returned float is not the same as the
state