[Python-checkins] python/dist/src/Doc/lib libitertools.tex, 1.28, 1.29

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Sat May 1 04:31:38 EDT 2004


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17351

Modified Files:
	libitertools.tex 
Log Message:
Minor documentation nits.

Index: libitertools.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libitertools.tex,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** libitertools.tex	20 Jan 2004 20:04:40 -0000	1.28
--- libitertools.tex	1 May 2004 08:31:36 -0000	1.29
***************
*** 34,38 ****
  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.
  Adopting the principles of just-in-time manufacturing, they create
--- 34,38 ----
  to be added to future versions of the module.
  
! Whether cast in pure python form or compiled code, tools that use iterators
  are more memory efficient (and faster) than their list based counterparts.
  Adopting the principles of just-in-time manufacturing, they create
***************
*** 378,382 ****
  
  >>> import operator
! >>> for cube in imap(operator.pow, xrange(1,4), repeat(3)):
  ...    print cube
  ...
--- 378,382 ----
  
  >>> import operator
! >>> for cube in imap(operator.pow, xrange(1,5), repeat(3)):
  ...    print cube
  ...
***************
*** 384,390 ****
  8
  27
  
  >>> reportlines = ['EuroPython', 'Roster', '', 'alex', '', 'laura',
!                   '', 'martin', '', 'walter', '', 'samuele']
  >>> for name in islice(reportlines, 3, None, 2):
  ...    print name.title()
--- 384,391 ----
  8
  27
+ 64
  
  >>> reportlines = ['EuroPython', 'Roster', '', 'alex', '', 'laura',
!                   '', 'martin', '', 'walter', '', 'mark']
  >>> for name in islice(reportlines, 3, None, 2):
  ...    print name.title()
***************
*** 394,398 ****
  Martin
  Walter
! Samuele
  
  # Show a dictionary sorted and grouped by value
--- 395,399 ----
  Martin
  Walter
! Mark
  
  # Show a dictionary sorted and grouped by value
***************
*** 423,430 ****
  \end{verbatim}
  
! This section shows how itertools can be combined to create other more
! powerful itertools.  Note that \function{enumerate()} and \method{iteritems()}
! already have efficient implementations.  They are included here
! to illustrate how higher level tools can be created from building blocks.
  
  \begin{verbatim}
--- 424,441 ----
  \end{verbatim}
  
! 
! \subsection{Recipes \label{itertools-recipes}}
! 
! This section shows recipes for creating an extended toolset using the
! existing itertools as building blocks.
! 
! 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 kept small by linking the tools together in a functional style
! which helps eliminate temporary variables.  High speed is retained by
! preferring ``vectorized'' building blocks over the use of for-loops and
! generators which incur interpreter overhead.
! 
  
  \begin{verbatim}
***************
*** 463,467 ****
  
  def padnone(seq):
!     "Returns the sequence elements and then returns None indefinitely"
      return chain(seq, repeat(None))
  
--- 474,482 ----
  
  def padnone(seq):
!     """Returns the sequence elements and then returns None indefinitely.
! 
!     Useful for emulating the behavior of the built-in map() function.
! 
!     """
      return chain(seq, repeat(None))
  
***************
*** 477,482 ****
  
  def repeatfunc(func, times=None, *args):
!     "Repeat calls to func with specified arguments."
!     "Example:  repeatfunc(random.random)"
      if times is None:
          return starmap(func, repeat(args))
--- 492,500 ----
  
  def repeatfunc(func, times=None, *args):
!     """Repeat calls to func with specified arguments.
!     
!     Example:  repeatfunc(random.random)
!     
!     """
      if times is None:
          return starmap(func, repeat(args))




More information about the Python-checkins mailing list