Skip to content

Commit 7709037

Browse files
authored
Small speed-up for the convolve() recipe. (GH-106371)
1 parent b4efdf8 commit 7709037

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Doc/library/itertools.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,8 +1085,8 @@ The following recipes have a more mathematical flavor:
10851085
kernel = tuple(kernel)[::-1]
10861086
n = len(kernel)
10871087
padded_signal = chain(repeat(0, n-1), signal, repeat(0, n-1))
1088-
for window in sliding_window(padded_signal, n):
1089-
yield math.sumprod(kernel, window)
1088+
windowed_signal = sliding_window(padded_signal, n)
1089+
return map(math.sumprod, repeat(kernel), windowed_signal)
10901090

10911091
def polynomial_from_roots(roots):
10921092
"""Compute a polynomial's coefficients from its roots.

0 commit comments

Comments
 (0)