diff options
author | Victor Stinner <vstinner@python.org> | 2020-06-05 00:56:37 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-05 00:56:37 (GMT) |
commit | e005ead49b1ee2b1507ceea94e6f89c28ecf1f81 (patch) | |
tree | f2846eec88f5539825acc200c3b8a3d91a3b7d0f /Include | |
parent | 78a02c2568714562e23e885b6dc5730601f35226 (diff) | |
download | cpython-e005ead49b1ee2b1507ceea94e6f89c28ecf1f81.zip cpython-e005ead49b1ee2b1507ceea94e6f89c28ecf1f81.tar.gz cpython-e005ead49b1ee2b1507ceea94e6f89c28ecf1f81.tar.bz2 |
bpo-40521: Make context free list per-interpreter (GH-20644)
Each interpreter now has its own context free list:
* Move context free list into PyInterpreterState.
* Add _Py_context_state structure.
* Add tstate parameter to _PyContext_ClearFreeList()
and _PyContext_Fini().
* Pass tstate to clear_freelists().
Diffstat (limited to 'Include')
-rw-r--r-- | Include/internal/pycore_context.h | 2 | ||||
-rw-r--r-- | Include/internal/pycore_gc.h | 2 | ||||
-rw-r--r-- | Include/internal/pycore_interp.h | 7 |
3 files changed, 9 insertions, 2 deletions
diff --git a/Include/internal/pycore_context.h b/Include/internal/pycore_context.h index f665ad5..ea4b3c8 100644 --- a/Include/internal/pycore_context.h +++ b/Include/internal/pycore_context.h @@ -37,6 +37,6 @@ struct _pycontexttokenobject { int _PyContext_Init(void); -void _PyContext_Fini(void); +void _PyContext_Fini(PyThreadState *tstate); #endif /* !Py_INTERNAL_CONTEXT_H */ diff --git a/Include/internal/pycore_gc.h b/Include/internal/pycore_gc.h index ad2e552..fd3fb7f 100644 --- a/Include/internal/pycore_gc.h +++ b/Include/internal/pycore_gc.h @@ -171,7 +171,7 @@ extern void _PyFloat_ClearFreeList(PyThreadState *tstate); extern void _PyList_ClearFreeList(PyThreadState *tstate); extern void _PyDict_ClearFreeList(void); extern void _PyAsyncGen_ClearFreeLists(PyThreadState *tstate); -extern void _PyContext_ClearFreeList(void); +extern void _PyContext_ClearFreeList(PyThreadState *tstate); #ifdef __cplusplus } diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h index d624218..4f81102 100644 --- a/Include/internal/pycore_interp.h +++ b/Include/internal/pycore_interp.h @@ -124,6 +124,12 @@ struct _Py_async_gen_state { int asend_numfree; }; +struct _Py_context_state { + // List of free PyContext objects + PyContext *freelist; + int numfree; +}; + /* interpreter state */ @@ -223,6 +229,7 @@ struct _is { struct _Py_float_state float_state; struct _Py_frame_state frame; struct _Py_async_gen_state async_gen; + struct _Py_context_state context; /* Using a cache is very effective since typically only a single slice is created and then deleted again. */ |