On Thursday, September 7, 2017 10:06:14 AM EDT Ethan Furman wrote: > 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 > You literally replace threading.local() with contextvars.ContextVar(): import threading _decimal_context = threading.local() def set_decimal_context(ctx): _decimal_context.context = ctx Becomes: import contextvars _decimal_context = contextvars.ContextVar('decimal.Context') def set_decimal_context(ctx): _decimal_context.set(ctx) Elvis
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