A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2017-September/149281.html below:

[Python-Dev] PEP 550 v4

[Python-Dev] PEP 550 v4 [Python-Dev] PEP 550 v4Greg Ewing greg.ewing at canterbury.ac.nz
Thu Sep 7 03:54:15 EDT 2017
Yury Selivanov wrote:
>     def foo():
>          var = ContextVar()
>          var.set(1)
> 
>     for _ in range(10**6): foo()
> 
> If 'var' is strongly referenced, we would have a bunch of them.

Erk. This is not how I envisaged context vars would be
used. What I thought you would do is this:

    my_context_var = ContextVar()

    def foo():
       my_context_var.set(1)

This problem would also not arise if context vars
simply had names instead of being magic key objects:

    def foo():
       contextvars.set("mymodule.myvar", 1)

That's another thing I think would be an improvement,
but it's orthogonal to what we're talking about here
and would be best discussed separately.

-- 
Greg
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