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



Szabolcs Horvát <szhorvat@xxxxxxxxx> writes:

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.)

I think that's right: anything with an __add__ method, apart from
string, can be sum()ed.

--
Arnaud
.



Relevant Pages