Hi -
I thought that with the first class support for subinterpreters finally in the stdlib, my extrainterpreters pet project would be rendered all but obsolete.
Nonetheless, I made a new release this week, changing just (and just) the importing names so that it could function with Python 3.14.
To my surprise, it still provides by default a lot of niceties the stdlib concurrent.interpreter.Interpreter wrapper won’t achieve.
If for nothing else, I welcome you to play around with it (and the unfinished data structures within the code) so that we can improve it, and ultimately get new ideas/patterns that could be useful to a shared-data concurrent execution model (there is a nice proposal now as the pre-PEP 805 )
This is mostly pure-Python, with a simple extension to create a cross-interpreter lock - (and a way to cast a memory address (pointer) to a new Python object reference - at the time one could not import ctypes, which allows this in the sub-interpreter. ctypes works now)
For an example, this is what is possible (from Python 3.12 - 3.14):
>>> import extrainterpreters as ET
>>> bb = ET.Interpreter()
>>>
>>> bb.start()
Sub-Interpreter <#2>
>>> import math
>>> def bla():
... print(math.cos(0))
>>> bb.run(bla)
1.0
This will automatically check the loaded modules in sys.modules, and import the same modules in the sub-interpreter - and serialize ‘bla’ (once it figures out it is not in a file to be imported) using inspect.getsource so that it exists in the subinterpreter as well.
You are welcome to try and test.