From 13e4a4172122aaa3abca483cbe24b98e935e81ff Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sun, 4 Aug 2019 12:04:09 -0700 Subject: [PATCH 1/2] Remove suggestion that is less relevant now that global lookups are much faster --- Doc/library/itertools.rst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index b3a0a5f5192da1..64fac494da947a 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -913,9 +913,3 @@ which incur interpreter overhead. result.append(pool[-1-n]) return tuple(result) -Note, many of the above recipes can be optimized by replacing global lookups -with local variables defined as default values. For example, the -*dotproduct* recipe can be written as:: - - def dotproduct(vec1, vec2, sum=sum, map=map, mul=operator.mul): - return sum(map(mul, vec1, vec2)) From 1e84df09e18abd39ae8c907b7af9552761c291b0 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sun, 4 Aug 2019 12:34:43 -0700 Subject: [PATCH 2/2] Add link for installing the recipes --- Doc/library/itertools.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index 64fac494da947a..a3f403a5b40b9c 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -691,6 +691,12 @@ Itertools Recipes This section shows recipes for creating an extended toolset using the existing itertools as building blocks. +Substantially all of these recipes and many, many others can be installed from +the `more-itertools project `_ found +on the Python Package Index:: + + pip install more-itertools + The extended tools offer the same high performance as the underlying toolset. The superior memory performance is kept by processing elements one at a time rather than bringing the whole iterable into memory all at once. Code volume is