[Python-ideas] math.fsum: summing multiple running sums at once

Ilya Shlyakhter ilya_shl at alum.mit.edu
Tue Apr 27 19:55:30 CEST 2010


A suggestion: extend math.fsum to accept an iterable that yields
tuples of floats, and returns a tuple of sums.
This would permit summing multiple running sums at once (e.g. keeping
both a sum and a sum-of-squares for computing
standard deviation from an iterable), or summing a stream of complex numbers.

An alternative would be to make an object-oriented version of fsum
that has a method for adding a number to the sum;
then an array of such objects could be used to sum multiple iterables
simultaneously.

It would also be good if other methods based on fsum were included in
the standard library, e.g. for accurately computing
the mean and stddev of an iterable.

Thanks,

ilya



More information about the Python-ideas mailing list