From d720fef356778f99629b47866428f4791d809384 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 6 May 2020 17:41:05 +0200 Subject: [PATCH 1/2] bpo-40521: Disable list free list in subinterpreters When Python is built with experimental isolated interpreters, disable list free list. Temporary workaround until this cache is made per-interpreter. --- Objects/listobject.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index 904bea317c9da8..ffc4eb4c824d72 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -98,8 +98,15 @@ list_preallocate_exact(PyListObject *self, Py_ssize_t size) /* Empty list reuse scheme to save calls to malloc and free */ #ifndef PyList_MAXFREELIST -#define PyList_MAXFREELIST 80 +# define PyList_MAXFREELIST 80 #endif + +/* bpo-40521: tuple free lists are shared by all interpreters. */ +#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS +# undef PyList_MAXFREELIST +# define PyList_MAXFREELIST 0 +#endif + static PyListObject *free_list[PyList_MAXFREELIST]; static int numfree = 0; From bcfa9ca7e2ab29391d62acca57ff43e928c30d23 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 6 May 2020 18:24:26 +0200 Subject: [PATCH 2/2] Fix typo --- Objects/listobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index ffc4eb4c824d72..37fadca129ac02 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -101,7 +101,7 @@ list_preallocate_exact(PyListObject *self, Py_ssize_t size) # define PyList_MAXFREELIST 80 #endif -/* bpo-40521: tuple free lists are shared by all interpreters. */ +/* bpo-40521: list free lists are shared by all interpreters. */ #ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS # undef PyList_MAXFREELIST # define PyList_MAXFREELIST 0