[Python-Dev] PEP 550 v4 (original) (raw)
Koos Zevenhoven k7hoven at gmail.com
Wed Sep 6 11:07:36 EDT 2017
- Previous message (by thread): [Python-Dev] PEP 550 v4
- Next message (by thread): [Python-Dev] PEP 550 v4
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Sep 6, 2017 at 10:07 AM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
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 + -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20170906/cbf23a1e/attachment.html>
- Previous message (by thread): [Python-Dev] PEP 550 v4
- Next message (by thread): [Python-Dev] PEP 550 v4
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]