[Python-Dev] PEP 550 v4
yselivanov.ml at gmail.com
Wed Sep 6 13:22:29 EDT 2017
On Wed, Sep 6, 2017 at 8:07 AM, Koos Zevenhoven <k7hoven at gmail.com> wrote:
> On Wed, Sep 6, 2017 at 10:07 AM, Greg Ewing <greg.ewing at canterbury.ac.nz>
>> Yury Selivanov wrote:
>>> Greg, have you seen this new section:
>> That section seems to be addressing the idea of a generator
>> behaving differently depending on whether you use yield-from
>> on it.
> Regarding this, I think yield from should have the same semantics as
> iterating over the generator with next/send, and PEP 555 has no issues with
>> I never suggested that, and I'm still not suggesting it.
>>> The bottomline is that it's easier to
>>> reason about context when it's guaranteed that context changes are
>>> always isolated in generators no matter what.
>> I don't see a lot of value in trying to automagically
>> isolate changes to global state *only* in generators.
>> Under PEP 550, if you want to e.g. change the decimal
>> context temporarily in a non-generator function, you're
>> still going to have to protect those changes using a
>> with-statement or something equivalent. I don't see
>> why the same thing shouldn't apply to generators.
>> It seems to me that it will be *more* confusing to give
>> generators this magical ability to avoid with-statements.
> Exactly. To state it clearly: PEP 555 does not have this issue.
It would be great if you or Greg could show a couple of real-world
examples showing the "issue" (with the current PEP 550
PEP 550 treats coroutines and generators as objects that support out
of order execution. OS threads are similar to them in some ways. I
find it questionable to try to enforce context management rules we
have for regular functions to generators/coroutines. I don't really
understand the "refactoring" argument you and Greg are talking about
all the time.
PEP 555 still doesn't clearly explain how exactly it is different from
PEP 550. Because 555 was posted *after* 550, I think that it's PEP
555 that should have that comparison.
More information about the Python-Dev