[Python-Dev] Timeout for PEP 550 / Execution Context discussion

Ethan Furman ethan at stoneleaf.us
Mon Oct 16 14:12:39 EDT 2017

On 10/16/2017 09:11 AM, Yury Selivanov wrote:

> Question: why do we want EC objects to be mappings?  I'd rather make
> them opaque, which will result in less code and make it more
> future-proof.
> The key arguments for keeping ContextVar abstraction:
> * Naturally avoids name clashes.
> * Allows to implement efficient caching.  This is important if we want
> libraries like decimal/numpy to start using it.
> * Abstracts away the actual implementation of the EC.  This is a
> future-proof solution, with which we can enable EC support for
> generators in the future.  We already know two possible solutions (PEP
> 550 v1, PEP 550 current), and ContextVar is a good enough abstraction
> to support both of them.
> IMO ContextVar.set() and ContextVar.get() is a simple and nice API to
> work with the EC.  Most people (aside framework authors) won't even
> need to work with EC objects directly anyways.

Framework/library authors are users too.  Please don't make the interface unpleasant to use.

What would be really nice is to have attribute access like thread locals.  Instead of working with individual 
ContextVars you grab the LocalContext and access the vars as attributes.  I don't recall reading in the PEP why this is 
a bad idea.


More information about the Python-Dev mailing list