peps: 3c9e17945a3c (original) (raw)
--- a/pep-0201.txt +++ b/pep-0201.txt @@ -1,5 +1,5 @@ PEP: 201 -Title: Parallel Iteration +Title: Lockstep Iteration Version: RevisionRevisionRevision Author: bwarsaw@beopen.com (Barry A. Warsaw) Python-Version: 2.0 @@ -10,14 +10,14 @@ Post-History: 27-Jul-2000 Introduction
- This PEP describes the `parallel iteration' proposal for Python
- 2.0, previously known as `parallel for loops'. This PEP tracks
- the status and ownership of this feature, slated for introduction
- in Python 2.0. It contains a description of the feature and
- outlines changes necessary to support the feature. This PEP
- summarizes discussions held in mailing list forums, and provides
- URLs for further information, where appropriate. The CVS revision
- history of this file contains the definitive historical record.
- This PEP describes the `lockstep iteration' proposal for Python
- 2.0. This PEP tracks the status and ownership of this feature,
- slated for introduction in Python 2.0. It contains a description
- of the feature and outlines changes necessary to support the
- feature. This PEP summarizes discussions held in mailing list
- forums, and provides URLs for further information, where
- appropriate. The CVS revision history of this file contains the
- definitive historical record.
Motivation @@ -33,9 +33,9 @@ Motivation iterations by introducing a new builtin function called `zip'. -Parallel For-Loops +Lockstep For-Loops
- Lockstep for-loops are non-nested iterations over two or more sequences, such that at each pass through the loop, one element from each sequence is taken to compose the target. This behavior can already be accomplished in Python through the use of the map() @@ -70,10 +70,10 @@ Parallel For-Loops [(1, 4), (2, 5), (3, 6), (None, 7)] For these reasons, several proposals were floated in the Python
- 2.0 beta time frame for providing a better spelling of lockstep for-loops. The initial proposals centered around syntactic changes to the for statement, but conflicts and problems with the
- syntax were unresolvable, especially when lockstep for-loops were combined with another proposed feature called `list comprehensions' (see pep-0202.txt). @@ -140,21 +140,23 @@ Examples Reference Implementation Here is a reference implementation, in Python of the zip()
def zip(*args): if not args: raise TypeError('zip() expects one or more sequence arguments') ret = []
# find the length of the shortest sequence[](#l1.71)
shortest = min(*map(len, args))[](#l1.72)
for i in range(shortest):[](#l1.73)
item = [][](#l1.74)
for s in args:[](#l1.75)
item.append(s[i])[](#l1.76)
ret.append(tuple(item))[](#l1.77)
return ret[](#l1.78)
i = 0[](#l1.79)
try:[](#l1.80)
while 1:[](#l1.81)
item = [][](#l1.82)
for s in args:[](#l1.83)
item.append(s[i])[](#l1.84)
ret.append(tuple(item))[](#l1.85)
i = i + 1[](#l1.86)
except IndexError:[](#l1.87)
return ret[](#l1.88)
BDFL Pronouncements @@ -165,8 +167,8 @@ BDFL Pronouncements - The function's name. An earlier version of this PEP included an open issue listing 20+ proposed alternative names to zip(). In the face of no overwhelmingly better choice, the BDFL strongly
prefers zip() due to it's Haskell[2] heritage. See version 1.7[](#l1.96)
of this PEP for the list of alteratives.[](#l1.97)
prefers zip() due to its Haskell[2] heritage. See version 1.7[](#l1.98)
of this PEP for the list of alternatives.[](#l1.99)