[Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.45, 1.46 (original) (raw)
rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Wed May 19 18:30:28 EDT 2004
- Previous message: [Python-checkins] python/nondist/peps pep-0000.txt, 1.271, 1.272 pep-0289.txt, 1.11, 1.12 pep-0320.txt, 1.10, 1.11 pep-0322.txt, 1.17, 1.18 pep-0329.txt, 1.4, 1.5
- Next message: [Python-checkins] python/dist/src/Lib imaplib.py,1.67,1.68
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18496
Modified Files: whatsnew24.tex Log Message: Improved wording for generator expressions.
Index: whatsnew24.tex
RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** whatsnew24.tex 19 May 2004 19:45:19 -0000 1.45
--- whatsnew24.tex 19 May 2004 22:30:25 -0000 1.46
***************
*** 15,20 ****
\tableofcontents
! This article explains the new features in Python 2.4. No release date
! for Python 2.4 has been set; expect that this will happen mid-2004.
While Python 2.3 was primarily a library development release, Python
--- 15,20 ----
\tableofcontents
! This article explains the new features in Python 2.4. The release
! date is expected to be around September 2004.
While Python 2.3 was primarily a library development release, Python
***************
*** 92,101 ****
\section{PEP 229: Generator Expressions}
! Generator expressions create in-line generators using a syntax similar
! to list comprehensions but with parenthesis instead of the surrounding
! brackets.
!
! Genexps allow simple generators to be constructed without a separate function
! definition. Writing:
\begin{verbatim}
--- 92,101 ----
\section{PEP 229: Generator Expressions}
! Now, simple generators can be coded succinctly as expressions using a syntax
! like list comprehensions but with parentheses instead of brackets. These
! expressions are designed for situations where the generator is used right
! away by an enclosing function. Generator expressions are more compact but
! less versatile than full generator definitions and the tend to be more memory
! friendly than equivalent list comprehensions.
\begin{verbatim}
***************
*** 122,130 ****
more readily than with list comprehensions.
! Generator expressions are intended to be used inside functions
! such as \function{sum()}, \function{min()}, \function{set()}, and
! \function{dict()}. These functions consume their data all at once
! and would not benefit from having a full list instead of a generator
! as an input:
\begin{verbatim}
--- 122,128 ----
more readily than with list comprehensions.
! Generator expressions are best used in functions that consume their
! data all at once and would not benefit from having a full list instead
! of a generator as an input:
\begin{verbatim}
***************
*** 150,158 ****
\end{verbatim}
- These examples show the intended use for generator expressions
- in situations where the values get consumed immediately after the
- generator is created. In these situations, they operate like
- memory efficient versions of list comprehensions.
For more complex uses of generators, it is strongly recommended that the traditional full generator definitions be used instead. In a --- 148,151 ----
*** 160,167 **** as soon as the expression is defined while the other expressions do not get evaluated until the generator is run. This nuance is never ! an issue when the generator is used immediately. If it is not used ! right away, then it is better to write a full generator definition ! which more clearly reveals when the expressions are evaluated and is ! more obvious about the visibility and lifetime of its looping variables.
\begin{seealso} --- 153,160 ---- as soon as the expression is defined while the other expressions do not get evaluated until the generator is run. This nuance is never ! an issue when the generator is used immediately; however, if it is not ! used right away, a full generator definition would be much more clear ! about when the sub-expressions are evaluated and would be more obvious ! about the visibility and lifetime of the variables.
\begin{seealso}
- Previous message: [Python-checkins] python/nondist/peps pep-0000.txt, 1.271, 1.272 pep-0289.txt, 1.11, 1.12 pep-0320.txt, 1.10, 1.11 pep-0322.txt, 1.17, 1.18 pep-0329.txt, 1.4, 1.5
- Next message: [Python-checkins] python/dist/src/Lib imaplib.py,1.67,1.68
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]