Yury Selivanov <yseliva...@gmail.com> added the comment:

Thank you, Stefan.  I've updated the PR with an asyncio+decimal test and run 
tests in refleak mode to make sure there's no regression there.

If during the beta/rc period we see that contextvars isn't stable enough or 
something I'll revert this change before 3.7.0 myself, so that decimal users 
will not be disturbed.

I'll merge the PR once the CI is green.

> Yes, that's the big question. In the generator discussions people were 
> advised to use "with" whenever possible, so I assume short blocks *will* be 
> used.

Yes, I used decimal examples all the time to showcase how context is supposed 
to work with generators.  Most of those examples were specifically constructed 
to illustrate some point, but I don't think that real-world code uses a 'with 
localcontext()' statement in every function.

Unfortunately there's no way (at least known to me) to make 'ContextVar.set()' 
faster than it is now.  I use HAMT which guarantees that all set operations 
will have O(log n) performance; the other known approach is to use 
copy-on-write (as in .NET), but that has an O(n) ContextVar.set() performance.  
So I guess a slightly slower 'with localcontext()' is the price to pay to make 
decimal easier to use for async/await code.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32630>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to