bpo-40521: Disable list free list in subinterpreters (GH-19959) · python/cpython@b7aa23d

Original file line numberDiff line numberDiff line change

@@ -98,8 +98,15 @@ list_preallocate_exact(PyListObject *self, Py_ssize_t size)

9898
9999

/* Empty list reuse scheme to save calls to malloc and free */

100100

#ifndef PyList_MAXFREELIST

101-

#define PyList_MAXFREELIST 80

101+

# define PyList_MAXFREELIST 80

102102

#endif

103+
104+

/* bpo-40521: list free lists are shared by all interpreters. */

105+

#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS

106+

# undef PyList_MAXFREELIST

107+

# define PyList_MAXFREELIST 0

108+

#endif

109+
103110

static PyListObject *free_list[PyList_MAXFREELIST];

104111

static int numfree = 0;

105112