[Python-Dev] PEP 554 v2 (new "interpreters" module)
stefan at bytereef.org
Fri Sep 8 19:28:42 EDT 2017
On Fri, Sep 08, 2017 at 04:04:27PM -0700, Eric Snow wrote:
> * "stdlib support for subinterpreters adds extra burden
> on C extension authors"
> In the ``Interpreter Isolation`` section below we identify ways in
> which isolation in CPython's subinterpreters is incomplete. Most
> notable is extension modules that use C globals to store internal
> state. PEP 3121 and PEP 489 provide a solution for most of the
> problem, but one still remains. [petr-c-ext]_ Until that is resolved,
> C extension authors will face extra difficulty to support
It's a bit of a hassle, and the enormous slowdown in some of the existing
solutions is really a no go .
In the case of _decimal, the tls-context is already subinterpreter safe
and reasonable fast due to caching.
The most promising model to me is to put *all* globals in a tls structure
and cache the whole structure. Extrapolating from my experiences with the
context, this might have a slowdown of "only" 4%.
Still, the argument "who uses subinterpreters?" of course still remains.
 I'm referring to the slowdown of heaptypes + module state.
More information about the Python-Dev