[Python-checkins] CVS: python/nondist/peps pep-0201.txt,1.4,1.5
Barry Warsaw
python-dev@python.org
Tue, 25 Jul 2000 14:51:58 -0700
Update of /cvsroot/python/python/nondist/peps
In directory slayer.i.sourceforge.net:/tmp/cvs-serv12662
Modified Files:
pep-0201.txt
Log Message:
In a compromise with JHy, and to be more consistent with the style now
documented in PEP1, remove the Emacs page breaks.
Also, Owner: -> Author:, added Created: and Post-History: headers
Changed "Standard For-Loops" section to "Motivation" and shortened
considerably; readers already know how for-loops work in Python.
Added notes about Guido's veto of lazy evaluation.
Index: pep-0201.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0201.txt,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** pep-0201.txt 2000/07/24 17:40:00 1.4
--- pep-0201.txt 2000/07/25 21:51:55 1.5
***************
*** 2,11 ****
Title: Parallel Iteration
Version: $Revision$
! Owner: bwarsaw@beopen.com (Barry A. Warsaw)
Python-Version: 2.0
Status: Draft
-
Introduction
--- 2,12 ----
Title: Parallel Iteration
Version: $Revision$
! Author: bwarsaw@beopen.com (Barry A. Warsaw)
Python-Version: 2.0
Status: Draft
+ Created: 13-Jul-2000
+ Post-History:
Introduction
***************
*** 20,59 ****
!
! Standard For-Loops
! Motivation for this feature has its roots in a concept described
! as `parallel for loops'. A standard for-loop in Python iterates
! over every element in the sequence until the sequence is
! exhausted. A `break' statement inside the loop suite causes an
! explicit loop exit. For-loops also have else: clauses which get
! executed when the loop exits normally (i.e. not by execution of a
! break).
!
! For-loops can iterate over built-in types such as lists and
! tuples, but they can also iterate over instance types that conform
! to an informal sequence protocol. This protocol states that the
! instance should implement the __getitem__() method, expecting a
! monotonically increasing index starting at 0, and this method
! should raise an IndexError when the sequence is exhausted. This
! protocol is currently undocumented -- a defect in Python's
! documentation hopefully soon corrected.
- For-loops are described in the Python language reference
- manual[1].
- An example for-loop:
-
- >>> for i in (1, 2, 3): print i
- ...
- 1
- 2
- 3
-
- In this example, the variable `i' is called the `target', and is
- assigned the next element of the list, each time through the loop.
-
-
-
Parallel For-Loops
--- 21,37 ----
! Motivation
! Standard for-loops in Python iterate over every element in a
! sequence until the sequence is exhausted[1]. However, for-loops
! iterate over only a single sequence, and it is often desirable to
! loop over more than one sequence, in a lock-step, "Chinese Menu"
! type of way.
!
! The common idioms used to accomplish this are unintuitive and
! inflexible. This PEP proposes a standard way of performing such
! iterations by introducing a new builtin function called `zip'.
Parallel For-Loops
***************
*** 71,80 ****
(2, 5)
(3, 6)
-
- Here, map() returns a list of N-tuples, where N is the number of
- sequences in map()'s argument list (after the initial `None').
- Each tuple is constructed of the i-th elements from each of the
- argument lists, specifically in this example:
-
>>> map(None, a, b)
[(1, 4), (2, 5), (3, 6)]
--- 49,52 ----
***************
*** 107,111 ****
-
The Proposed Solution
--- 79,82 ----
***************
*** 130,134 ****
-
Lazy Execution
--- 101,104 ----
***************
*** 139,144 ****
on demand.
!
Examples
--- 109,115 ----
on demand.
+ Guido is strongly opposed to lazy execution. See Open Issues.
!
Examples
***************
*** 195,199 ****
-
Reference Implementation
--- 166,169 ----
***************
*** 293,297 ****
-
Rejected Elaborations
--- 263,266 ----
***************
*** 353,359 ****
-
Open Issues
- What should "zip(a)" do? Given
--- 322,331 ----
Open Issues
+ - Guido opposes lazy evaluation for zip(). He believes zip()
+ should return a real list, with an xzip() lazy evaluator added
+ later if necessary.
+
- What should "zip(a)" do? Given
***************
*** 428,432 ****
-
References
--- 400,403 ----
***************
*** 436,440 ****
TBD: URL to python-dev archives
-
Copyright
--- 407,410 ----