[Python-ideas] Cofunctions - Back to Basics

Paul Moore p.f.moore at gmail.com
Thu Oct 27 15:18:08 CEST 2011


On 27 October 2011 13:19, Steven D'Aprano <steve at pearwood.info> wrote:
> As a PEP goes, this makes way too many assumptions about the reader's
> knowledge of a small corner of Python. Coroutines themselves are relatively
> new, and hardly in wide-spread use; yield from hasn't even made it into a
> production version of Python yet. But adding new syntax and built-ins will
> effect *all* Python programmers, not just the few who use coroutines.

I have only really skimmed the PEP, although I've been following this
thread so far. And I agree heartily with this comment (and indeed with
most of Steven's points). The whole proposal seems to me to be adding
a lot of language machinery (at least one new keyword, a new builtin
and C API, plus some fairly complex semantic changes) to address a
problem that I can't even really understand.

To be honest, I think that if a solution this heavyweight is
justified, it really should be possible to demonstrate a few
compelling examples of the problem, which can be understood without a
deep understanding of coroutines. The examples may be relatively
shallow (my understanding of why yield from is good was nothing more
than 'having to write "for x in gen(): yield x" all the time is a
pain') but they should be comprehensible to the average user.

It also seems premature to build this PEP on the as yet unreleased
yield from statement, before we have any real world experience of how
well (or badly) the issues the PEP alludes to can be handled in
current Python. I'd love to ask for examples of working code (and
preferably real world applications), plus a demonstration of how the
PEP simplifies it - but that's not possible in any current version of
Python...

Paul.

PS On the other hand, this is python-ideas, so I guess it's the right
place for blue-sky theorising. If that's all this thread is, maybe I
should simply ignore it for 18 months or so... :-)



More information about the Python-ideas mailing list