From 68bd808284a79b63b63db7a7bdddd40a5070e5d0 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Mon, 20 Mar 2023 23:52:41 -0500 Subject: [PATCH] The pow() variant further improves accuracy --- Doc/library/itertools.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index 2427a8d85f841c..78f64ea67e2542 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):