A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2017-October/149884.html below:

[Python-Dev] Timeout for PEP 550

[Python-Dev] Timeout for PEP 550 / Execution Context discussionEthan Furman ethan at stoneleaf.us
Mon Oct 16 22:29:44 EDT 2017
On 10/16/2017 05:29 PM, Nathaniel Smith wrote:
> On Mon, Oct 16, 2017 at 11:12 AM, Ethan Furman wrote:

>> 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.
>
> You're mixing up levels -- the way threading.local objects work is
> that there's one big dict that's hidden inside the interpreter (in the
> ThreadState), and it holds a separate little dict for each
> threading.local. The dict holding ContextVars is similar to the big
> dict; a threading.local itself is like a ContextVar that holds a dict.
> (And the reason it's this way is that it's easy to build either
> version on top of the other, and we did some survey of threading.local
> usage and the ContextVar style usage was simpler in the majority of
> cases.)
>
> For threading.local there's no way to get at the big dict at all from
> Python; it's hidden inside the C APIs and threading internals. I'm
> guessing you've never missed this :-). For ContextVars we can't hide
> it that much, because async frameworks need to be able to swap the
> current dict when switching tasks and clone it when starting a new
> task, but those are the only absolutely necessary operations.

Ah, thank you.

--
~Ethan~

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4