From a4a4286ce1cb18ddede45deb4e18a50274058f90 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Fri, 28 Jul 2000 05:48:25 +0000 Subject: [PATCH] Parallel => Lockstep everywhere. Replaced the reference implementation with one that's closer to what the C code will actually look like; i.e. it obeys the iteration protocol. Other grammar and spelling fixes. --- pep-0201.txt | 52 +++++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/pep-0201.txt b/pep-0201.txt index 86b3db6d3..8e9108561 100644 --- a/pep-0201.txt +++ b/pep-0201.txt @@ -1,5 +1,5 @@ PEP: 201 -Title: Parallel Iteration +Title: Lockstep Iteration Version: $Revision$ 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 - Parallel for-loops are non-nested iterations over two or more + 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 parallel + 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 parallel for-loops were + 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() - built-in function. These would ultimately be replaced by - equivalent C code. + built-in function. This will be replaced with a C implementation + after final approval. def zip(*args): if not args: raise TypeError('zip() expects one or more sequence arguments') ret = [] - # find the length of the shortest sequence - shortest = min(*map(len, args)) - for i in range(shortest): - item = [] - for s in args: - item.append(s[i]) - ret.append(tuple(item)) - return ret + i = 0 + try: + while 1: + item = [] + for s in args: + item.append(s[i]) + ret.append(tuple(item)) + i = i + 1 + except IndexError: + return ret 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 - of this PEP for the list of alteratives. + prefers zip() due to its Haskell[2] heritage. See version 1.7 + of this PEP for the list of alternatives. - zip() shall be a built-in function.