[Python-checkins] [3.12] Small speed-up for the convolve() recipe. (GH-106371) (GH-106375)
rhettinger
webhook-mailer at python.org
Mon Jul 3 16:49:13 EDT 2023
https://github.com/python/cpython/commit/67127ca8e2e9c94619503390267467fb3ee216e1
commit: 67127ca8e2e9c94619503390267467fb3ee216e1
branch: 3.12
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: rhettinger <rhettinger at users.noreply.github.com>
date: 2023-07-03T15:49:09-05:00
summary:
[3.12] Small speed-up for the convolve() recipe. (GH-106371) (GH-106375)
files:
M Doc/library/itertools.rst
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
index 56d6599798af2..a2d1798a2c6da 100644
--- a/Doc/library/itertools.rst
+++ b/Doc/library/itertools.rst
@@ -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.
More information about the Python-checkins
mailing list