[Python-checkins] The pow() variant further improves accuracy (GH-102866)
rhettinger
webhook-mailer at python.org
Tue Mar 21 01:02:21 EDT 2023
https://github.com/python/cpython/commit/1a5a14183ec807ead1c6a46464540159124e5260
commit: 1a5a14183ec807ead1c6a46464540159124e5260
branch: main
author: Raymond Hettinger <rhettinger at users.noreply.github.com>
committer: rhettinger <rhettinger at users.noreply.github.com>
date: 2023-03-21T00:02:14-05:00
summary:
The pow() variant further improves accuracy (GH-102866)
files:
M Doc/library/itertools.rst
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
index 2427a8d85f84..78f64ea67e25 100644
--- a/Doc/library/itertools.rst
+++ b/Doc/library/itertools.rst
@@ -876,7 +876,7 @@ which incur interpreter overhead.
n = len(coefficients)
if n == 0:
return x * 0 # coerce zero to the type of x
- powers = accumulate(repeat(x, n - 1), operator.mul, initial=1)
+ powers = map(pow, repeat(x), range(n))
return math.sumprod(reversed(coefficients), powers)
def polynomial_from_roots(roots):
More information about the Python-checkins
mailing list