(original) (raw)
Yury Selivanov wrote:
Greg, have you seen this new section:
https://www.python.org/dev/peps/pep-0550/#should-yield-from- leak-context-changes
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 this.
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.
––Koos
+ Koos Zevenhoven + http://twitter.com/k7hoven +