[Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.8, 1.9

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Wed Nov 12 11:39:32 EST 2003


Update of /cvsroot/python/python/dist/src/Doc/whatsnew
In directory sc8-pr-cvs1:/tmp/cvs-serv9727
Modified Files:
	whatsnew24.tex 
Log Message:
Explain the advantages of reversed.
Index: whatsnew24.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** whatsnew24.tex	12 Nov 2003 16:27:50 -0000	1.8
--- whatsnew24.tex	12 Nov 2003 16:39:30 -0000	1.9
***************
*** 35,39 ****
 
 \begin{verbatim}
! >>> for i in reversed([1,2,3]):
 ... print i
 ... 
--- 35,39 ----
 
 \begin{verbatim}
! >>> for i in reversed(xrange(1,4)):
 ... print i
 ... 
***************
*** 43,49 ****
 \end{verbatim}
 
 Note that \function{reversed()} only accepts sequences, not arbitrary
! iterators. If you want to reverse an iterator, convert it to 
! a list or tuple with \function{list()} or \function{tuple()}.
 
 \begin{verbatim}
--- 43,52 ----
 \end{verbatim}
 
+ Compared to extended slicing, \code{range(1,4)[::-1]}, \function{reversed()}
+ is easier to read, runs faster, and uses substantially less memory.
+ 
 Note that \function{reversed()} only accepts sequences, not arbitrary
! iterators. If you want to reverse an iterator, first convert it to 
! a list with \function{list()}.
 
 \begin{verbatim}


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /