<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Oct 15, 2017 at 8:17 PM, Nathaniel Smith <span dir="ltr"><<a href="mailto:njs@pobox.com" target="_blank">njs@pobox.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Sun, Oct 15, 2017 at 6:33 PM, Yury Selivanov <<a href="mailto:yselivanov.ml@gmail.com">yselivanov.ml@gmail.com</a>> wrote:<br>
> Stage 1. A new execution context PEP to solve the problem *just for<br>
> async code*.  The PEP will target Python 3.7 and completely ignore<br>
> synchronous generators and asynchronous generators.  It will be based<br>
> on PEP 550 v1 (no chained lookups, immutable mapping or CoW as an<br>
> optimization) and borrow some good API decisions from PEP 550 v3+<br>
> (contextvars module, ContextVar class).  The API (and C-API) will be<br>
> designed to be future proof and ultimately allow transition to the<br>
> stage 2.<br>
<br>
</div></div>If you want to ignore generators/async generators, then I think you<br>
don't even want PEP 550 v1, you just want something like a<br>
{set,get}_context_state API that lets you access the ThreadState's<br>
context dict (or rather, an opaque ContextState object that holds the<br>
context dict), and then task schedulers can call them at appropriate<br>
moments.<span class="HOEnZb"></span><br clear="all"></blockquote></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">Yes, that's what I meant by "ignoring generators". And I'd like there to be a "current context" that's a per-thread MutableMapping with ContextVar keys. Maybe there's not much more to it apart from naming the APIs for getting and setting it? To be clear, I am fine with this being a specific subtype of MutableMapping. But I don't see much benefit in making it more abstract than that.<br></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div>