mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Small speed-up for the convolve() recipe. (GH-106371)
This commit is contained in:
parent
b4efdf8cda
commit
7709037095
1 changed files with 2 additions and 2 deletions
|
@ -1085,8 +1085,8 @@ The following recipes have a more mathematical flavor:
|
||||||
kernel = tuple(kernel)[::-1]
|
kernel = tuple(kernel)[::-1]
|
||||||
n = len(kernel)
|
n = len(kernel)
|
||||||
padded_signal = chain(repeat(0, n-1), signal, repeat(0, n-1))
|
padded_signal = chain(repeat(0, n-1), signal, repeat(0, n-1))
|
||||||
for window in sliding_window(padded_signal, n):
|
windowed_signal = sliding_window(padded_signal, n)
|
||||||
yield math.sumprod(kernel, window)
|
return map(math.sumprod, repeat(kernel), windowed_signal)
|
||||||
|
|
||||||
def polynomial_from_roots(roots):
|
def polynomial_from_roots(roots):
|
||||||
"""Compute a polynomial's coefficients from its roots.
|
"""Compute a polynomial's coefficients from its roots.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue