diff options
author | Donghee Na <donghee.na@python.org> | 2024-01-15 15:38:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-15 15:38:57 (GMT) |
commit | 3eae76554b0687c6b9c5c019cc53bb76430488c9 (patch) | |
tree | f57ef0919140b9603434f854b40054150c18f54f /Include | |
parent | 44e47dfba55a825ce7c340b1460cb493165353c9 (diff) | |
download | cpython-3eae76554b0687c6b9c5c019cc53bb76430488c9.zip cpython-3eae76554b0687c6b9c5c019cc53bb76430488c9.tar.gz cpython-3eae76554b0687c6b9c5c019cc53bb76430488c9.tar.bz2 |
gh-111968: Use per-thread slice_cache in free-threading (gh-113972)
Diffstat (limited to 'Include')
-rw-r--r-- | Include/internal/pycore_freelist.h | 9 | ||||
-rw-r--r-- | Include/internal/pycore_gc.h | 1 | ||||
-rw-r--r-- | Include/internal/pycore_interp.h | 3 | ||||
-rw-r--r-- | Include/internal/pycore_sliceobject.h | 2 |
4 files changed, 11 insertions, 4 deletions
diff --git a/Include/internal/pycore_freelist.h b/Include/internal/pycore_freelist.h index 3400943..faa0c11 100644 --- a/Include/internal/pycore_freelist.h +++ b/Include/internal/pycore_freelist.h @@ -59,10 +59,19 @@ struct _Py_float_state { #endif }; +struct _Py_slice_state { +#ifdef WITH_FREELISTS + /* Using a cache is very effective since typically only a single slice is + created and then deleted again. */ + PySliceObject *slice_cache; +#endif +}; + typedef struct _Py_freelist_state { struct _Py_float_state float_state; struct _Py_tuple_state tuple_state; struct _Py_list_state list_state; + struct _Py_slice_state slice_state; } _PyFreeListState; #ifdef __cplusplus diff --git a/Include/internal/pycore_gc.h b/Include/internal/pycore_gc.h index c029b23..f8e86a2 100644 --- a/Include/internal/pycore_gc.h +++ b/Include/internal/pycore_gc.h @@ -249,6 +249,7 @@ extern void _Py_ClearFreeLists(_PyFreeListState *state, int is_finalization); extern void _PyTuple_ClearFreeList(_PyFreeListState *state, int is_finalization); extern void _PyFloat_ClearFreeList(_PyFreeListState *state, int is_finalization); extern void _PyList_ClearFreeList(_PyFreeListState *state, int is_finalization); +extern void _PySlice_ClearCache(_PyFreeListState *state); extern void _PyDict_ClearFreeList(PyInterpreterState *interp); extern void _PyAsyncGen_ClearFreeLists(PyInterpreterState *interp); extern void _PyContext_ClearFreeList(PyInterpreterState *interp); diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h index dadc8e3..134a882 100644 --- a/Include/internal/pycore_interp.h +++ b/Include/internal/pycore_interp.h @@ -187,9 +187,6 @@ struct _is { struct _Py_long_state long_state; struct _dtoa_state dtoa; struct _py_func_state func_state; - /* Using a cache is very effective since typically only a single slice is - created and then deleted again. */ - PySliceObject *slice_cache; struct _Py_tuple_state tuple; struct _Py_dict_state dict_state; diff --git a/Include/internal/pycore_sliceobject.h b/Include/internal/pycore_sliceobject.h index 98665c3..0c72d3e 100644 --- a/Include/internal/pycore_sliceobject.h +++ b/Include/internal/pycore_sliceobject.h @@ -11,7 +11,7 @@ extern "C" { /* runtime lifecycle */ -extern void _PySlice_Fini(PyInterpreterState *); +extern void _PySlice_Fini(_PyFreeListState *); extern PyObject * _PyBuildSlice_ConsumeRefs(PyObject *start, PyObject *stop); |