[3.12] GH-121439: Allow PyTupleObjects with an ob_size of 20 in the free_list to be reused (gh-121428) (#121566)

GH-121439: Allow PyTupleObjects with an ob_size of 20 in the free_list to be reused (gh-121428)
(cherry picked from commit 9585a1a2a2)

Co-authored-by: satori1995 <132636720+satori1995@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2024-07-10 10:06:41 +02:00 committed by GitHub
parent e1a223431f
commit ac4276cc7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View file

@ -0,0 +1 @@
Allow tuples of length 20 in the freelist to be reused.

View file

@ -1139,7 +1139,7 @@ maybe_freelist_pop(Py_ssize_t size)
return NULL; return NULL;
} }
assert(size > 0); assert(size > 0);
if (size < PyTuple_MAXSAVESIZE) { if (size <= PyTuple_MAXSAVESIZE) {
Py_ssize_t index = size - 1; Py_ssize_t index = size - 1;
PyTupleObject *op = STATE.free_list[index]; PyTupleObject *op = STATE.free_list[index];
if (op != NULL) { if (op != NULL) {