[issue2785] alternate fast builtin sum
Raymond Hettinger
report at bugs.python.org
Thu May 8 09:45:11 CEST 2008
Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:
The approach of using separate accumulations is intrinsically flawed if
you want the same result as a regular sum(). Here's a small dataset
that shows why you can't accumulate separate sums by type:
>>> d = [1000000000000000, -
1000000000000000.0, .0000000000000001, .0000000000000001]
>>> sum(d)
2e-16
>>> d[0] + sum(d[1:])
0.0
Closing this one. The approach is doomed and the possible benefits
over the current approach are microscopic at best and only apply to
unusual corner cases.
I also prefer the current approach because it is easily extended to
LongLongs and it is easy to show that the code is correct (at least
with respect to producing the same result as a regular sum()).
----------
resolution: -> rejected
status: open -> closed
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2785>
__________________________________
More information about the Python-bugs-list
mailing list