Oh, I like that. It does feel like a property of the variable. (But can you
efficiently enumerate all context vars when creating a thread?)
I imagine that thread pools add some complication, because you don’t want
to inherit these accidentally between tasks run by the same worker.
On Thu, Aug
On Thu, Aug 19, 2021 at 8:43 AM Guido van Rossum wrote:
> Perhaps we need a library for creating/managing threads that inherits all
> current context values?
>
Or is it a "kind of context variable that is shared among threads?" That
was more the direction my mind was going.
Context variables
asyncio.to_thread creates threads that inherit the current context, according
to https://www.python.org/dev/peps/pep-0567/#rationale the decimal module
should use contextvars for this too
___
Python-ideas mailing list -- python-ideas@python.org
To
Perhaps we need a library for creating/managing threads that inherits all
current context values?
On Thu, Aug 19, 2021 at 7:48 AM Paul Prescod wrote:
> There are certain values that are managed independent of any specific
> code-accessible object. The decimal precision is a good example:
>
>
There are certain values that are managed independent of any specific
code-accessible object. The decimal precision is a good example:
https://docs.python.org/3/library/decimal.html
We can call these context variables. As your code shows, the true "home" of the
"prec" value is not some object
On 18Aug2021 16:30, Paul Prescod wrote:
>Let's imagine I have an algorithm which depends on a context variable.
>
>I write an algorithm (elided below for space) which depends on it. Then I
>realize that I can improve the performance of my algorithm by using
>concurrent.futures. But my algorithm