[Python-Dev] PEP 567 v2
Elvis Pranskevichus
elprans at gmail.com
Fri Jan 5 18:23:34 EST 2018
On Friday, January 5, 2018 5:43:24 PM EST Chris Jerdonek wrote:
> Is there a reason ContextVar needs to be exposed publicly at all? For
> example, the API could use string keys like contextvars.get(name) or
> Context.get(name) (class method). There could be separate functions
> to initialize keys with desired default values, etc (internally
> creating ContextVars as needed).
Mainly because the design of contextvars follows the spirit of
threading.local() (but see [1]). A ContextVar is not unlike a global
variable, and we don't normally write globals()['foo'].
Elvis
[1] https://www.python.org/dev/peps/pep-0550/#replication-of-threading-local-interface
More information about the Python-Dev
mailing list