Re: Feature suggestion: sum() ought to use a compensated summation algorithm



Hallöchen!

Erik Max Francis writes:

Szabolcs Horvát wrote:

Arnaud Delobelle wrote:

sum() works for any sequence of objects with an __add__ method, not
just floats! Your algorithm is specific to floats.

This occurred to me also, but then I tried

sum(['abc', 'efg'], '')

and it did not work. Or is this just a special exception to
prevent the misuse of sum to join strings? (As I said, I'm only
an occasional user.)

What you wrote is nonsensical there, no different from 'a' + 1 --
which is why it quite rightly raises a TypeError.

No, the above expression should yield ''+'abc'+'efg', look for the
signature of sum in the docs.

Tschö,
Torsten.

--
Torsten Bronger, aquisgrana, europa vetus
Jabber ID: bronger@xxxxxxxxxx
(See http://ime.webhop.org for further contact info.)
.



Relevant Pages