Feature suggestion: sum() ought to use a compensated summation algorithm
Szabolcs Horvát
szhorvat at gmail.com
Mon May 5 03:37:38 EDT 2008
Gabriel Genellina wrote:
>
> Python doesn't require __add__ to be associative, so this should not be used as a general sum replacement.
It does not _require_ this, but using an __add__ that is not commutative
and associative, or has side effects, would qualify as a serious misuse,
anyway. So I think that this isn't a real disadvantage (it can always
be documented that sum() expects __add__ to have these properties).
But you are right that summing floats with a requirement of high
precision is a quite specific use case, so there are no serious
arguments to do this, either.
More information about the Python-list
mailing list