]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
The pow() variant further improves accuracy (GH-102866)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Tue, 21 Mar 2023 05:02:14 +0000 (00:02 -0500)
committerGitHub <noreply@github.com>
Tue, 21 Mar 2023 05:02:14 +0000 (00:02 -0500)
Doc/library/itertools.rst

index 2427a8d85f841cae7f3e3d9c514b2096bb691f03..78f64ea67e25420e290cc2109c463becf079a259 100644 (file)
@@ -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):