[Python-Dev] PEP 289 - Generator Expressions - Let's Move Forward

Jeremy Hylton jeremy at alum.mit.edu
Fri Apr 23 15:41:32 EDT 2004


On Fri, 2004-04-23 at 15:02, Michael Chermside wrote:
> > I'd like to get generator expressions checked into CVS.
> >
> > Regarding the early-or-late binding issue, here's what I'd like to see
> > happen: I'd like the late-binding (i.e. non-capture) version checked
> > in and released with Python 2.4a1 and a2.  If we find there are real
> > problems with these semantics, we can switch to early-binding
> > semantics in 2.4b1
> 
> Sounds like a good plan, but I have one question: Given the extent to
> which alpha releases are tested (and subtracting out those who use
> them only to check old code for compatibility and don't try out the
> new features) are we going to be able to tell if there are problems
> with the semantics?

We need reports from people writing real code with generator
expressions.  It's hard to guess if we'll get enough substantial
feedback in the alpha releases.  The kind of issues we're dealing with
usually manifest themselves in real programs rather than toy examples;
not sure that an alpha will get that kind of use.

On the other hand, a generator expression is nearly equivalent to a list
comprehension.  So it should be easy for people to experiment with
generator expressions, because they can swap them with list
comprehensions in many cases.

That leads me to wonder what exactly the rationale for generator
expressions is.  The PEP says that "time, clarity, and memory are
conserved by using an generator expression" but I can only see how
memory is conserved.  That is, I don't find them any easier to read than
list comprehensions and I don't understand the performance implications
very well.  It's not obvious to me that their faster.

> My best idea is that those who currently favor the early-binding
> approach (and I'm sure you've heard from plenty of them) should be
> encouraged to try it out in the alpha and report any issues, along

I'm not sure what you mean by "it." If you mean try the alpha with
late-binding semantics and see how it goes, I think that's a good plan.

> with actual use cases. Someone collects these responses, then you
> (Guido) look over the results (with a grain of salt since it's
> mostly being tested by folks who object) and decide if it's a
> problem.

Jeremy





More information about the Python-Dev mailing list