Feature suggestion: sum() ought to use a compensated summationalgorithm

Rhamphoryncus rhamph at gmail.com
Fri May 9 12:12:46 EDT 2008


On May 8, 3:09 pm, "Terry Reedy" <tjre... at udel.edu> wrote:
> "Szabolcs Horvát" <szhor... at gmail.com> wrote in message
>
> news:fvmdg1$1e4p$1 at toralf.uib.no...| 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,
>
> seq + seq is not commutative ;-)

There's no point switching to a special algorithm unless a float is
detected.  What you're really arguing is seq + seq + float is not
commutative.  In either case we may have to hurt you. ;)



More information about the Python-list mailing list