[Python-Dev] PEP 550 v4 (original) (raw)
Ethan Furman ethan at stoneleaf.us
Thu Sep 7 10:06:14 EDT 2017
- Previous message (by thread): [Python-Dev] PEP 550 v4
- Next message (by thread): [Python-Dev] PEP 550 v4
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 09/07/2017 06:41 AM, Elvis Pranskevichus wrote:
On Thursday, September 7, 2017 9:05:58 AM EDT Ethan Furman wrote:
The disagreement seems to be whether a LogicalContext should be created implicitly vs explicitly (or opt-out vs opt-in). As a user trying to track down a decimal context change not propagating, I would not suspect the above code of automatically creating a LogicalContext and isolating the change, whereas Greg's context manager version is abundantly clear.
The implicit vs explicit argument comes down, I think, to resource management: some resources in Python are automatically managed (memory), and some are not (files) -- which type should LCs be? You are confusing resource management with the isolation mechanism. PEP 550 contextvars are analogous to threading.local(), which the PEP makes very clear from the outset.
I might be, and I wouldn't be surprised. :) On the other hand, one can look at isolation as being a resource.
threading.local(), the isolation mechanism, is implicit.
I don't think so. You don't get threading.local() unless you call it -- that makes it explicit.
decimal.localcontext() is an explicit resource manager that relies on threading.local() magic. PEP 550 simply provides a threading.local() alternative that works in tasks and generators. That's it!
The concern is how PEP 550 provides it:
explicitly, like threading.local(): has to be set up manually, preferably with a context manager
implicitly: it just happens under certain conditions
--
Ethan
- Previous message (by thread): [Python-Dev] PEP 550 v4
- Next message (by thread): [Python-Dev] PEP 550 v4
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]