[Python-Dev] PEP 550 v4

Yury Selivanov yselivanov.ml at gmail.com
Wed Sep 6 20:13:07 EDT 2017

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:

1. your single-threaded code
2. a generator
3. 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():

    # decimal context is not set

    # or
    yield from generator()
    # decimal context is still not set

I consider that the above is a feature.


More information about the Python-Dev mailing list