Re: Feature suggestion: sum() ought to use a compensated summation algorithm
- From: Arnaud Delobelle <arnodel@xxxxxxxxxxxxxx>
- Date: Sat, 03 May 2008 21:38:21 +0100
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
.
- References:
- Feature suggestion: sum() ought to use a compensated summation algorithm
- From: Szabolcs Horvát
- Re: Feature suggestion: sum() ought to use a compensated summation algorithm
- From: Arnaud Delobelle
- Re: Feature suggestion: sum() ought to use a compensated summation algorithm
- From: Szabolcs Horvát
- Feature suggestion: sum() ought to use a compensated summation algorithm
- Prev by Date: dict invert - learning question
- Next by Date: Daily WTF with XML, or error handling in SAX
- Previous by thread: Re: Feature suggestion: sum() ought to use a compensated summation algorithm
- Next by thread: Re: Feature suggestion: sum() ought to use a compensated summation algorithm
- Index(es):
Relevant Pages
|