[Python-Dev] Scope, not context? (was Re: PEP 550 v3 naming)

Yury Selivanov yselivanov.ml at gmail.com
Thu Aug 24 11:13:12 EDT 2017

On Thu, Aug 24, 2017 at 10:38 AM, Barry Warsaw <barry at python.org> wrote:

I'll snip the naming discussion for now, I'm really curious to see
what other people will say.

> A different tack would more closely align with PEP 550’s heritage in thread-local storage, calling these things “execution storage”.  I think I read Guido suggest elsewhere using a namespace here so that in common code you’d only have to change the “threading.local()” call to migrate to PEP 550.  It might be neat if you could do something like:
> import execution
> els = execution.local()
> els.x = 1

A couple of relevant updates on this topic in old python-ideas threads
(I'm not sure you've seen them):


Unfortunately it's not feasible to re-use the "local()" idea for PEP
550.  The "local()" semantics imposes many constraints and
complexities to the design, while offering only "users already know
it" argument for it.

And even if we had "execution.local()" API, it would not be safe to
always replace every "theading.local()" with it. Sometimes what you
need is an actual TLS.  Sometimes your design actually depends on it,
even if you are not aware of that.  Updating existing libraries to use
PEP 550 should be a very conscious decision, simply because it has
different semantics/guarantees.


More information about the Python-Dev mailing list