Skip to content

Commit

Permalink
Small speed-up for convolve() recipe.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhettinger committed Jul 3, 2023
1 parent 2028a4f commit 4c4bc60
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Doc/library/itertools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 4c4bc60

Please sign in to comment.