mirror of https://github.com/python/cpython
Small speed-up for the convolve() recipe. (GH-106371)
This commit is contained in:
parent
b4efdf8cda
commit
7709037095
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue