-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
At this point it makes sense to have a PEP about the plan for a per-interpreter GIL. This will be a companion to PEP 554. The PEP will cover the following (but more focused than #77):
- discuss about interpreter isolation
- what are we isolating?
- benefits and costs
- extent
- cannot share mutable state
- cannot share (mutable) objects; all objects are mutable due to refcount
- summary of global variables that must be fixed (e.g. made per-interpreter)
- explain how most of work is worth doing anyway
- challenges
- objects exposed in public C-API, incl. limited API and stable ABI
- breakage due to existing runtime bugs that get exposed by subinterpreters
- breakage when moving extensions to PEP 630 due to existing bugs (see python/steering-council#99)
- summarize immortal objects (see the PEP and faster-cpython/ideas#276)
- allows us to share otherwise immutable objects (e.g. str, None)
- cover the alternatives (e.g. lookup funcs + C-API hacks)
- for now, assume that the immortal objects PEP will be accepted (if it isn't, update this PEP with the alternatives)
- discuss impact
- mention similarities (and differences) with Javascript's worker threads
- I'd rather avoid any confusion, but @vstinner even suggested changing the term from "subinterpreter" to "worker thread", in the context of the use case I have in mind
- outline the plan (see #78)
- prep for per-interpreter
- fix all globals in core/builtins (e.g. consolidate to
_PyRuntimeState
, use atomics, replace) - fix all globals in stdlib extensions (e.g. use module state)
- explicitly support subinterpreters in all stdlib extension modules, AKA PEP 630 (see bpo-40077 & the SC discussion)
- deal with objects held by static types (e.g.
__subclasses__
)
- fix all globals in core/builtins (e.g. consolidate to
- update import system to enforce restrictions on extension modules
- move most data from
_PyRuntimeState
toPyInterpreterState
- move the GIL to
PyInterpreterState
- make the
PyConfig
changes
- prep for per-interpreter
- specified changes
- C-API:
PyConfig
options:- deprecate the existing "isolated" option (too general)
- add: disallow fork
- add: disallow additional threads
- add: always run in own thread
- add: share the GIL with the main interpreter
- others?
- default for all the above: behave the same as <3.8 (AKA "legacy mode")
- C-API: add anything missing that is necessary to implement PEP 554 as an extension on PyPI (in case it doesn't make it in time)
- update import system to enforce restrictions on
- others?
- C-API:
I'm not quite sure, but I'll probably post this PEP before we reach a conclusion on the immortal objects PEP.
bratao
Metadata
Metadata
Assignees
Labels
No labels