[Python-Dev] PEP 567 (contextvars) idea: really implement the current context (original) (raw)
Nathaniel Smith njs at pobox.com
Wed Jan 3 21:15:32 EST 2018
- Previous message (by thread): [Python-Dev] PEP 567 (contextvars) idea: really implement the current context
- Next message (by thread): [Python-Dev] PEP 567 (contextvars) idea: really implement the current context
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Jan 3, 2018 at 5:42 PM, Victor Stinner <victor.stinner at gmail.com> wrote:
Hi,
It seems like many people, including myself, are confused by the lack of concrete current context in the PEP 567 (contextvars). But it isn't difficult to implement the current context (I implemented it, see below).
The problem with such an API is that it doesn't work (or at the very least creates a lot of complications) in a potential future PEP 550 world, where the "current context" becomes something like a ChainMap-of-Contexts instead of just the last Context that had run() called on it. This isn't a big problem for contextvars.get_context(), which returns a snapshot of the current context -- in a PEP 550 world it would return a snapshot of the current "effective" (flattened) context.
Maybe it would help a little to rename get_context() to something like snapshot_context()?
-n
-- Nathaniel J. Smith -- https://vorpus.org
- Previous message (by thread): [Python-Dev] PEP 567 (contextvars) idea: really implement the current context
- Next message (by thread): [Python-Dev] PEP 567 (contextvars) idea: really implement the current context
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]