Re: Feature suggestion: sum() ought to use a compensated summation algorithm
- From: Torsten Bronger <bronger@xxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 03 May 2008 23:27:08 +0200
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.)
.
- Follow-Ups:
- Re: Feature suggestion: sum() ought to use a compensated summation algorithm
- From: Erik Max Francis
- Re: Feature suggestion: sum() ought to use a compensated summation algorithm
- 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
- Re: Feature suggestion: sum() ought to use a compensated summation algorithm
- From: Erik Max Francis
- Feature suggestion: sum() ought to use a compensated summation algorithm
- Prev by Date: Re: Feature suggestion: sum() ought to use a compensated summation algorithm
- Next by Date: Re: Feature suggestion: sum() ought to use a compensated summation algorithm
- 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
|