[Python-Dev] PEP 550 v4

Yury Selivanov yselivanov.ml at gmail.com
Wed Sep 6 10:42:52 EDT 2017


On Wed, Sep 6, 2017 at 5:58 AM, Ivan Levkivskyi <levkivskyi at gmail.com> wrote:
> On 6 September 2017 at 11:13, Nathaniel Smith <njs at pobox.com> wrote:
>>
>> On Wed, Sep 6, 2017 at 1:49 AM, Ivan Levkivskyi <levkivskyi at gmail.com>
>> wrote:
>> > Normal generators fall out from this "scheme", and it looks like their
>> > behavior is determined by the fact that coroutines are implemented as
>> > generators. What I think miht help is to add few more motivational
>> > examples
>> > to the design section of the PEP.
>>
>> Literally the first motivating example at the beginning of the PEP
>> ('def fractions ...') involves only generators, not coroutines.
>
>
> And this is probably what confuses people. As I understand, the
> tasks/coroutines are among the primary motivations for the PEP,
> but they appear somewhere later. There are four potential ways to see the
> PEP:
>
> 1) Generators are broken*, and therefore coroutines are broken, we want to
> fix the latter therefore we fix the former.
> 2) Coroutines are broken, we want to fix them and let's also fix generators
> while we are at it.
> 3) Generators are broken, we want to fix them and let's also fix coroutines
> while we are at it.
> 4) Generators and coroutines are broken in similar ways, let us fix them as
> consistently as we can.

Ivan, generators and coroutines are fundamentally different objects
(even though they share the implementation). The only common thing is
that they both allow for out of order execution of code in the same OS
thread.  The PEP explains the semantical difference of EC in the
High-level Specification in detail, literally on the 2nd page of the
PEP.  I don't see any benefit in reshuffling the rationale section.

Yury


More information about the Python-Dev mailing list