summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-06-04 22:50:05 (GMT)
committerGitHub <noreply@github.com>2020-06-04 22:50:05 (GMT)
commit2ba59370c3dda2ac229c14510e53a05074b133d1 (patch)
tree88cd810f62d0c5ae34a83a10e05268e33ea0da57 /Include
parent69ac6e58fd98de339c013fe64cd1cf763e4f9bca (diff)
downloadcpython-2ba59370c3dda2ac229c14510e53a05074b133d1.zip
cpython-2ba59370c3dda2ac229c14510e53a05074b133d1.tar.gz
cpython-2ba59370c3dda2ac229c14510e53a05074b133d1.tar.bz2
bpo-40521: Make float free list per-interpreter (GH-20636)
Each interpreter now has its own float free list: * Move tuple numfree and free_list into PyInterpreterState. * Add _Py_float_state structure. * Add tstate parameter to _PyFloat_ClearFreeList() and _PyFloat_Fini().
Diffstat (limited to 'Include')
-rw-r--r--Include/internal/pycore_gc.h2
-rw-r--r--Include/internal/pycore_interp.h9
-rw-r--r--Include/internal/pycore_pylifecycle.h2
3 files changed, 11 insertions, 2 deletions
diff --git a/Include/internal/pycore_gc.h b/Include/internal/pycore_gc.h
index e8e5d32..f90d80b 100644
--- a/Include/internal/pycore_gc.h
+++ b/Include/internal/pycore_gc.h
@@ -167,7 +167,7 @@ PyAPI_FUNC(void) _PyGC_InitState(struct _gc_runtime_state *);
// Functions to clear types free lists
extern void _PyFrame_ClearFreeList(void);
extern void _PyTuple_ClearFreeList(PyThreadState *tstate);
-extern void _PyFloat_ClearFreeList(void);
+extern void _PyFloat_ClearFreeList(PyThreadState *tstate);
extern void _PyList_ClearFreeList(void);
extern void _PyDict_ClearFreeList(void);
extern void _PyAsyncGen_ClearFreeLists(void);
diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h
index b90bfbe..c0eed00 100644
--- a/Include/internal/pycore_interp.h
+++ b/Include/internal/pycore_interp.h
@@ -84,6 +84,14 @@ struct _Py_tuple_state {
#endif
};
+struct _Py_float_state {
+ /* Special free list
+ free_list is a singly-linked list of available PyFloatObjects,
+ linked via abuse of their ob_type members. */
+ int numfree;
+ PyFloatObject *free_list;
+};
+
/* interpreter state */
@@ -178,6 +186,7 @@ struct _is {
PyLongObject* small_ints[_PY_NSMALLNEGINTS + _PY_NSMALLPOSINTS];
#endif
struct _Py_tuple_state tuple;
+ struct _Py_float_state float_state;
};
/* Used by _PyImport_Cleanup() */
diff --git a/Include/internal/pycore_pylifecycle.h b/Include/internal/pycore_pylifecycle.h
index 3f2ff5b..2643abc 100644
--- a/Include/internal/pycore_pylifecycle.h
+++ b/Include/internal/pycore_pylifecycle.h
@@ -64,7 +64,7 @@ extern void _PyTuple_Fini(PyThreadState *tstate);
extern void _PyList_Fini(void);
extern void _PySet_Fini(void);
extern void _PyBytes_Fini(void);
-extern void _PyFloat_Fini(void);
+extern void _PyFloat_Fini(PyThreadState *tstate);
extern void _PySlice_Fini(void);
extern void _PyAsyncGen_Fini(void);