[Python-ideas] New PEP 550: Execution Context
Stefan Krah
stefan at bytereef.org
Sat Aug 12 06:33:39 EDT 2017
Yury Selivanov wrote:
> This is a new PEP to implement Execution Contexts in Python.
The idea is of course great!
A couple of issues for decimal:
> Moreover, passing the context explicitly does not work at all for
> libraries like ``decimal`` or ``numpy``, which use operator overloading.
Instead of "with localcontext() ...", each coroutine can create a new
Context() and use its methods, without any loss of functionality.
All one loses is the inline operator syntax sugar.
I'm aware you know all this, but the entire decimal paragraph sounds a bit
as if this option did not exist.
> Fast C API for packages like ``decimal`` and ``numpy``.
_decimal relies on caching the most recently used thread-local context,
which gives a speedup of about 25% for inline operators:
https://github.com/python/cpython/blob/master/Modules/_decimal/_decimal.c#L1639
Can this speed be achieved with the execution contexts? IOW, can the lookup
of an excecution context be as fast as PyThreadState_GET()?
Stefan Krah
More information about the Python-ideas
mailing list