]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Small speed-up for the convolve() recipe. (GH-106371)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Mon, 3 Jul 2023 20:38:38 +0000 (15:38 -0500)
committerGitHub <noreply@github.com>
Mon, 3 Jul 2023 20:38:38 +0000 (15:38 -0500)
Doc/library/itertools.rst

index 56d6599798af207c52c56a0f275d945884fa1718..a2d1798a2c6da13ee3a0f429d0aacf5e38c9dbed 100644 (file)
@@ -1085,8 +1085,8 @@ The following recipes have a more mathematical flavor:
        kernel = tuple(kernel)[::-1]
        n = len(kernel)
        padded_signal = chain(repeat(0, n-1), signal, repeat(0, n-1))
-       for window in sliding_window(padded_signal, n):
-           yield math.sumprod(kernel, window)
+       windowed_signal = sliding_window(padded_signal, n)
+       return map(math.sumprod, repeat(kernel), windowed_signal)
 
    def polynomial_from_roots(roots):
        """Compute a polynomial's coefficients from its roots.