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

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to