[Python-Dev] PEP 550 v4 (original) (raw)
Yury Selivanov yselivanov.ml at gmail.com
Wed Sep 6 20:13:07 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 4:27 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
Ivan Levkivskyi 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. This is what I disagree with. Generators don't implement coroutines, they implement parts of coroutines. We want "task local storage" that behaves analogously to thread local storage. But PEP 550 as it stands doesn't give us that; it gives something more like "function local storage" for certain kinds of function.
The PEP gives you a Task Local Storage, where Task is:
- your single-threaded code
- a generator
- an async task
If you correctly use context managers, PEP 550 works intuitively and similar to how one would think that threading.local() should work.
The only example you (and Koos) can come up with is this:
def generator():
set_decimal_context()
yield
next(generator())
# decimal context is not set
# or
yield from generator()
# decimal context is still not set
I consider that the above is a feature.
Yury
- 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 ]