Visitar URL original
GH-100425: Improve accuracy of builtin sum() for float inputs by rhettinger · Pull Request #100426 · python/cpython · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
For consistent results, apply compensation on the slow path as well.
  • Loading branch information
rhettinger committed Dec 23, 2022
commit 6c7894c82d2b2e562c2f72ef32745533917fbeee
3 changes: 3 additions & 0 deletions Python/bltinmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2572,6 +2572,9 @@ builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start)
continue;
}
}
if (c && Py_IS_FINITE(c)) {
f_result += c;
}
result = PyFloat_FromDouble(f_result);
if (result == NULL) {
Py_DECREF(item);
Expand Down