[Python-ideas] Exposing CPython's subinterpreter C-API in the stdlib.
ericsnowcurrently at gmail.com
Wed May 24 21:01:10 EDT 2017
Although I haven't been able to achieve the pace that I originally
wanted, I have been able to work on my multi-core Python idea
little-by-little. Most notably, some of the blockers have been
resolved at the recent PyCon sprints and I'm ready to move onto the
next step: exposing multiple interpreters via a stdlib module.
Initially I just want to expose basic support via 3 successive
changes. Below I've listed the corresponding (chained) PRs, along
with what they add. Note that the 2 proposed modules take some cues
from the threading module, but don't try to be any sort of
replacement. Threading and subinterpreters are two different features
that are used together rather than as alternatives to one another.
At the very least I'd like to move forward with the _interpreters
module sooner rather than later. Doing so will facilitate more
extensive testing of subinterpreters, in preparation for further use
of them in the multi-core Python project. We can iterate from there,
but I'd at least like to get the basic functionality landed early.
Any objections to (or feedback about) the low-level _interpreters
module as described? Likewise for the high-level interpreters module?
Discussion on any expanded functionality for the modules or on the
broader topic of the multi-core project are both welcome, but please
start other threads for those topics.
basic low-level API: https://github.com/python/cpython/pull/1748
_interpreters.create() -> id
_interpreters.run_string_unrestricted(id, code, ns=None) -> ns
extra low-level API: https://github.com/python/cpython/pull/1802
_interpreters.enumerate() -> [id, ...]
_interpreters.get_current() -> id
_interpreters.get_main() -> id
_interpreters.is_running(id) -> bool
basic high-level API: https://github.com/python/cpython/pull/1803
interpreters.enumerate() -> [Interpreter, ...]
interpreters.get_current() -> Interpreter
interpreters.get_main() -> Interpreter
interpreters.create() -> Interpreter
More information about the Python-ideas