cpython: 1026b1d47f30 (original) (raw)

Mercurial > cpython

changeset 83037:1026b1d47f30 2.7

Add an itertools recipe showing how to use t.__copy__().

Raymond Hettinger python@rcn.com
date Sat, 30 Mar 2013 23:37:57 -0700
parents e044d22d2f61
children cfd4cd15809e
files Doc/library/itertools.rst
diffstat 1 files changed, 12 insertions(+), 0 deletions(-)[+] [-] Doc/library/itertools.rst 12

line wrap: on

line diff

--- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -828,6 +828,18 @@ which incur interpreter overhead. indices = sorted(random.randrange(n) for i in xrange(r)) return tuple(pool[i] for i in indices)

+

+

+ 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::