-
Notifications
You must be signed in to change notification settings - Fork 6
3.2 The State of Subinterpreters in CPython
Eric Snow edited this page May 31, 2023
·
1 revision
(Also see the slides for my lightning talk at the 2020 Python language summit.)
While subinterpreters have been a part of C-Python for over 20 years, they haven't been heavily used. This is in large part because they were only exposed in the C-API (not in the stdlib) and the feature was not widely publicized. Furthermore, subinterpreters do not deal well with C global state. All this led to several problems:
- CPython changes did not always take subinterpreters into account
- subinterpreters were not well tested, leading to unresolved bugs
- extension modules can struggle in subinterpreters
- PEP 3121 "Extension module initialization and finalization"
- PEP 432 "Restructuring the CPython startup sequence"
- PEP 489 "Multi-phase extension module initialization"
- PEP 573 "Module State Access from C Extension Methods"
Key events:
- added: ...
- first used seriously: (mod_wsgi?) ...
- GILState incompatibility
- PEP 432
- PEP 489
Until relatively recently the only publicly known uses of subinterpreters were:
- mod_wsgi
- ???
However, in the last few years there has been an increased usage:
- OpenStack Ceph (https://github.com/ceph/ceph/pull/14971, https://tracker.ceph.com/issues/21157)
- JEP (https://github.com/ninia/jep/wiki/How-Jep-Works)
- WeeChat (https://bugs.python.org/issue44050 & https://github.com/poljar/weechat-matrix/issues/248)
- wee-slack (https://github.com/wee-slack/wee-slack/issues/812)
- kodi (https://bugzilla.redhat.com/show_bug.cgi?id=2034962)
- ...