[Python-Dev] Re: PEP 279

Raymond Hettinger python@rcn.com
Fri, 29 Mar 2002 08:34:08 -0500


> Subject: Re: [Python-Dev] Re: PEP 279
> From: Guido van Rossum <guido@python.org>
> Date: Fri, 29 Mar 2002 01:41:05 -0500

[GvR] >    I like the idea of having some way to iterate over a sequence and
[GvR] >    its index set in parallel.  It's fine for this to be a builtin.
>
[RDH] Great!

[RDH] > I like itercount() or enumerate().  The reason is that this
[RDH] > function can work with any iterable including those that
[RDH] > do not have numeric indices (such as dictionaries).
[RDH] > Counting or enumeration is what is really happening.
>
[GvR] I don't like either of those, you don't seem to like iterindexed(), so
[GvR] we'll have to think more about a name.

[Just]  I quite like the name enumerate. Hate itercount. I'm neutral on
indexed.

[RDH] > 3.  itercount(collection)                       # good enough
[GvR] I really hate the alternate count option, so let's agree to pick 3
[GvR] (with a different name).

Done!
Though my tastes are a little different, iterindexed() works just fine.
I'm agreed (agreeing with dictators is good for ones health :-) to
option three as you wrote it:

[GvR]     def iterindexed(collection):
[GvR]            i = 0
[GvR]            it = iter(collection)
[GvR]            while 1:
[GvR]            yield (i, it.next())
[GvR]              i += 1

Thank you.  I'll put it back it the PEP just like this and mark it
as Accepted.



> > > 2. Generator comprehensions

[GvR] If the only way to get you to stop asking for this is a -1 from me,
[GvR] I'll give it a -1.

Okay, I'll mark this one as rejected.  The rationale for the rejection
will be that the implementation and maintenance complexities
exceed the added value.  The added value would be minimal
because it's already easy to code the generator directly.

[RDH] > Several commenters wanted this one quite a bit.  An excerpt: "This
[RDH] > rules.  You rock."
[GvR] Yeah, if I left Python's design to Ping, it would become quite the
[GvR] clever hack. :-)

Poor Ping, getting a little public ribbing for foolishly supporting
my proposal <grin> when the comment actually came from Kragen Sitaker :)



> > > 3. Generator exception passing
>
[RDH] > I need help from others on py-dev who can articulate the need
clearly.
[RDH] > For me, it's as plain as day and I don't know what to say to convey
the
[RDH] > message better than it is expressed in the PEP.
>
[GvR] Too bad.  This one gets a big fat -1 until there's a good motivational
[GvR] section.

Okay, let's defer this one until the case for or against becomes stronger.
I'll move it to join the separate PEP for generator parameter passing.
Putting that one in a separate pep was necessary because it wasn't
yet ready for pronoucement.  I'll mark the two (exception passing
and parameter passing) as being proposed for 2.4 or later and note
that the case is not currently strong enough to warrant acceptance.


Executive Summary:
1.  iterindexed(collection)  -->  accepted
2.  gen comprehensions  -->  rejected
3.  gen exception passing  -->  deferred, needs case building
4.  gen parameter passing   -->  deferred, needs alternatives explored


Everyone, thank you for your time and thoughtful comments.  We're done.


Raymond Hettinger

_ ~
@ @
\_/