We also expose PyInterpreterConfig. This is part of the PEP 684 (per-interpreter GIL) implementation. We will add docs as soon as we can.
FYI, I'm adding the new config field for per-interpreter GIL in gh-99114.
int allow_threads;
int allow_daemon_threads;
int check_multi_interp_extensions;
-} _PyInterpreterConfig;
+} PyInterpreterConfig;
#define _PyInterpreterConfig_INIT \
{ \
PyAPI_FUNC(int) _Py_LegacyLocaleDetected(int warn);
PyAPI_FUNC(char *) _Py_SetLocaleFromEnv(int category);
-PyAPI_FUNC(PyStatus) _Py_NewInterpreterFromConfig(
+PyAPI_FUNC(PyStatus) Py_NewInterpreterFromConfig(
PyThreadState **tstate_p,
- const _PyInterpreterConfig *config);
+ const PyInterpreterConfig *config);
typedef void (*atexit_datacallbackfunc)(void *);
PyAPI_FUNC(int) _Py_AtExit(
--- /dev/null
+We've added ``Py_NewInterpreterFromConfig()`` and ``PyInterpreterConfig`` to
+the public C-API (but not the stable ABI; not yet at least). The new
+function may be used to create a new interpreter with various features
+configured. The function was added to support PEP 684 (per-interpreter
+GIL).
PyThreadState_Swap(NULL);
- const _PyInterpreterConfig config = {
+ const PyInterpreterConfig config = {
.use_main_obmalloc = use_main_obmalloc,
.allow_fork = allow_fork,
.allow_exec = allow_exec,
.allow_daemon_threads = allow_daemon_threads,
.check_multi_interp_extensions = check_multi_interp_extensions,
};
- PyStatus status = _Py_NewInterpreterFromConfig(&substate, &config);
+ PyStatus status = Py_NewInterpreterFromConfig(&substate, &config);
if (PyStatus_Exception(status)) {
/* Since no new thread state was created, there is no exception to
propagate; raise a fresh one after swapping in the old thread
// Create and initialize the new interpreter.
PyThreadState *save_tstate = _PyThreadState_GET();
- const _PyInterpreterConfig config = isolated
- ? (_PyInterpreterConfig)_PyInterpreterConfig_INIT
- : (_PyInterpreterConfig)_PyInterpreterConfig_LEGACY_INIT;
+ const PyInterpreterConfig config = isolated
+ ? (PyInterpreterConfig)_PyInterpreterConfig_INIT
+ : (PyInterpreterConfig)_PyInterpreterConfig_LEGACY_INIT;
// XXX Possible GILState issues?
PyThreadState *tstate = NULL;
- PyStatus status = _Py_NewInterpreterFromConfig(&tstate, &config);
+ PyStatus status = Py_NewInterpreterFromConfig(&tstate, &config);
PyThreadState_Swap(save_tstate);
if (PyStatus_Exception(status)) {
/* Since no new thread state was created, there is no exception to
static PyStatus
-init_interp_settings(PyInterpreterState *interp, const _PyInterpreterConfig *config)
+init_interp_settings(PyInterpreterState *interp,
+ const PyInterpreterConfig *config)
{
assert(interp->feature_flags == 0);
return status;
}
- const _PyInterpreterConfig config = _PyInterpreterConfig_LEGACY_INIT;
+ const PyInterpreterConfig config = _PyInterpreterConfig_LEGACY_INIT;
status = init_interp_settings(interp, &config);
if (_PyStatus_EXCEPTION(status)) {
return status;
*/
static PyStatus
-new_interpreter(PyThreadState **tstate_p, const _PyInterpreterConfig *config)
+new_interpreter(PyThreadState **tstate_p, const PyInterpreterConfig *config)
{
PyStatus status;
}
PyStatus
-_Py_NewInterpreterFromConfig(PyThreadState **tstate_p,
- const _PyInterpreterConfig *config)
+Py_NewInterpreterFromConfig(PyThreadState **tstate_p,
+ const PyInterpreterConfig *config)
{
return new_interpreter(tstate_p, config);
}
Py_NewInterpreter(void)
{
PyThreadState *tstate = NULL;
- const _PyInterpreterConfig config = _PyInterpreterConfig_LEGACY_INIT;
- PyStatus status = _Py_NewInterpreterFromConfig(&tstate, &config);
+ const PyInterpreterConfig config = _PyInterpreterConfig_LEGACY_INIT;
+ PyStatus status = new_interpreter(&tstate, &config);
if (_PyStatus_EXCEPTION(status)) {
Py_ExitStatusException(status);
}