[Python-checkins] python/dist/src/Doc/lib libitertools.tex,1.6,1.7

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
Tue, 22 Apr 2003 17:09:45 -0700


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv20534

Modified Files:
	libitertools.tex 
Log Message:
Add comment on performance.
Fix missing right parenthesis.
Add three examples.


Index: libitertools.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libitertools.tex,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** libitertools.tex	23 Feb 2003 04:40:07 -0000	1.6
--- libitertools.tex	23 Apr 2003 00:09:42 -0000	1.7
***************
*** 28,31 ****
--- 28,37 ----
  to form \code{imap(f, count())} and produce an equivalent result.
  
+ Likewise, the functional tools are designed to work well with the
+ high-speed functions provided by the \refmodule{operator} module.
+ 
+ The module author welcomes suggestions for other basic building blocks
+ to be added to future versions of the module.
+ 
  Whether cast in pure python form or C code, tools that use iterators
  are more memory efficient (and faster) than their list based counterparts.
***************
*** 34,39 ****
  computer equivalent of ``inventory''.
  
! The module author welcomes suggestions for other basic building blocks
! to be added to future versions of the module.
  
  \begin{seealso}
--- 40,46 ----
  computer equivalent of ``inventory''.
  
! The performance advantage of iterators becomes more acute as the number
! of elements increases -- at some point, lists grow large enough to
! to severely impact memory cache performance and start running slowly.
  
  \begin{seealso}
***************
*** 106,110 ****
    Note, this is the only member of the toolkit that may require
    significant auxiliary storage (depending on the length of the
!   iterable.
  \end{funcdesc}
  
--- 113,117 ----
    Note, this is the only member of the toolkit that may require
    significant auxiliary storage (depending on the length of the
!   iterable).
  \end{funcdesc}
  
***************
*** 355,358 ****
--- 362,376 ----
  ...     "s -> (s0,s1), (s1,s2), (s2, s3), ..."
  ...     return izip(seq, islice(seq,1,len(seq)))
+ 
+ >>> def padnone(seq):
+ ...     "Returns the sequence elements and then returns None indefinitely"
+ ...     return chain(seq, repeat(None))
+ 
+ >>> def ncycles(seq, n):
+ ...     "Returns the sequence elements n times"
+ ...     return chain(*repeat(seq, n))
+ 
+ >>> def dotproduct(vec1, vec2):
+ ...     return sum(imap(operator.mul, vec1, vec2))
  
  \end{verbatim}