On Wed, Sep 6, 2017 at 4:27 PM, Greg Ewing
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(): 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