diff options
author | Victor Stinner <vstinner@python.org> | 2019-11-20 01:27:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-20 01:27:56 (GMT) |
commit | 01b1cc12e7c6a3d6a3d27ba7c731687d57aae92a (patch) | |
tree | 1d1afefdc486c063853678d126975fe2d019059f /Include/internal | |
parent | eb1cbbff1cd8214836a492502e75e463ade6f673 (diff) | |
download | cpython-01b1cc12e7c6a3d6a3d27ba7c731687d57aae92a.zip cpython-01b1cc12e7c6a3d6a3d27ba7c731687d57aae92a.tar.gz cpython-01b1cc12e7c6a3d6a3d27ba7c731687d57aae92a.tar.bz2 |
bpo-36710: Add PyInterpreterState.runtime field (GH-17270)
Add PyInterpreterState.runtime field: reference to the _PyRuntime
global variable. This field exists to not have to pass runtime in
addition to tstate to a function. Get runtime from tstate:
tstate->interp->runtime.
Remove "_PyRuntimeState *runtime" parameter from functions already
taking a "PyThreadState *tstate" parameter.
_PyGC_Init() first parameter becomes "PyThreadState *tstate".
Diffstat (limited to 'Include/internal')
-rw-r--r-- | Include/internal/pycore_pylifecycle.h | 11 | ||||
-rw-r--r-- | Include/internal/pycore_pystate.h | 6 |
2 files changed, 8 insertions, 9 deletions
diff --git a/Include/internal/pycore_pylifecycle.h b/Include/internal/pycore_pylifecycle.h index 16baf10..f269ffe 100644 --- a/Include/internal/pycore_pylifecycle.h +++ b/Include/internal/pycore_pylifecycle.h @@ -38,15 +38,12 @@ extern PyStatus _PyFaulthandler_Init(int enable); extern int _PyTraceMalloc_Init(int enable); extern PyObject * _PyBuiltin_Init(PyThreadState *tstate); extern PyStatus _PySys_Create( - struct pyruntimestate *runtime, PyThreadState *tstate, PyObject **sysmod_p); extern PyStatus _PySys_SetPreliminaryStderr(PyObject *sysdict); extern PyStatus _PySys_ReadPreinitWarnOptions(PyWideStringList *options); extern PyStatus _PySys_ReadPreinitXOptions(PyConfig *config); -extern int _PySys_InitMain( - struct pyruntimestate *runtime, - PyThreadState *tstate); +extern int _PySys_InitMain(PyThreadState *tstate); extern PyStatus _PyImport_Init(PyThreadState *tstate); extern PyStatus _PyExc_Init(void); extern PyStatus _PyErr_Init(void); @@ -57,7 +54,7 @@ extern PyStatus _Py_HashRandomization_Init(const PyConfig *); extern PyStatus _PyTypes_Init(void); extern PyStatus _PyImportZip_Init(PyThreadState *tstate); -extern PyStatus _PyGC_Init(struct pyruntimestate *runtime); +extern PyStatus _PyGC_Init(PyThreadState *tstate); /* Various internal finalizers */ @@ -89,9 +86,7 @@ extern void _PyHash_Fini(void); extern void _PyTraceMalloc_Fini(void); extern void _PyWarnings_Fini(PyInterpreterState *interp); -extern void _PyGILState_Init( - struct pyruntimestate *runtime, - PyThreadState *tstate); +extern void _PyGILState_Init(PyThreadState *tstate); extern void _PyGILState_Fini(struct pyruntimestate *runtime); PyAPI_FUNC(void) _PyGC_DumpShutdownStats(struct pyruntimestate *runtime); diff --git a/Include/internal/pycore_pystate.h b/Include/internal/pycore_pystate.h index eb44ae9..fec64a7 100644 --- a/Include/internal/pycore_pystate.h +++ b/Include/internal/pycore_pystate.h @@ -62,6 +62,11 @@ struct _is { struct _is *next; struct _ts *tstate_head; + /* Reference to the _PyRuntime global variable. This field exists + to not have to pass runtime in addition to tstate to a function. + Get runtime from tstate: tstate->interp->runtime. */ + struct pyruntimestate *runtime; + int64_t id; int64_t id_refcount; int requires_idref; @@ -301,7 +306,6 @@ PyAPI_FUNC(void) _PyRuntime_Finalize(void); /* Other */ PyAPI_FUNC(void) _PyThreadState_Init( - _PyRuntimeState *runtime, PyThreadState *tstate); PyAPI_FUNC(void) _PyThreadState_DeleteExcept( _PyRuntimeState *runtime, |