[Python-Dev] PEP 554 v2 (new "interpreters" module)

Michel Desmoulin desmoulinmichel at gmail.com
Fri Sep 8 23:54:51 EDT 2017



Le 09/09/2017 à 01:28, Stefan Krah a écrit :
> 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
>> subinterpreters.
> 
> It's a bit of a hassle, and the enormous slowdown in some of the existing
> solutions is really a no go [1].
> 
> 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.

For now, nobody. But if we expose it and web frameworks manage to create
workers as fast as multiprocessing and as cheap as threading, you will
find a lot of people starting to want to use it.

We can't know until we got the toy to play with.


> 
> 
> 
> Stefan Krah
> 
> 
> [1] I'm referring to the slowdown of heaptypes + module state.
> 
> 
> 
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/desmoulinmichel%40gmail.com
> 


More information about the Python-Dev mailing list