From ac4276cc7af019e1f68552fe28da79a01327658a Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Wed, 10 Jul 2024 10:06:41 +0200 Subject: [PATCH] [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 9585a1a2a251aaa15baf6579e13dd3be0cb05f1f) Co-authored-by: satori1995 <132636720+satori1995@users.noreply.github.com> --- .../2024-07-08-02-24-55.gh-issue-121439.jDHod3.rst | 1 + Objects/tupleobject.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2024-07-08-02-24-55.gh-issue-121439.jDHod3.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-07-08-02-24-55.gh-issue-121439.jDHod3.rst b/Misc/NEWS.d/next/Core and Builtins/2024-07-08-02-24-55.gh-issue-121439.jDHod3.rst new file mode 100644 index 00000000000000..361f9fc71186c6 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2024-07-08-02-24-55.gh-issue-121439.jDHod3.rst @@ -0,0 +1 @@ +Allow tuples of length 20 in the freelist to be reused. diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 991edcc86677de..918654fae898e7 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -1139,7 +1139,7 @@ maybe_freelist_pop(Py_ssize_t size) return NULL; } assert(size > 0); - if (size < PyTuple_MAXSAVESIZE) { + if (size <= PyTuple_MAXSAVESIZE) { Py_ssize_t index = size - 1; PyTupleObject *op = STATE.free_list[index]; if (op != NULL) {