Skip to content

Commit 2a56327

Browse files
committed
stack resize rule
1 parent 3070c67 commit 2a56327

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Modules/_functoolsmodule.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,9 @@ partial_vectorcall(PyObject *self, PyObject *const *args,
504504
Py_XDECREF(pto_kw_merged);
505505

506506
/* Resize Stack if the call has more than 6 keywords
507-
* (1% of github use cases have 7 or more kwds) */
508-
if (nkwds > 6 && stack != small_stack) {
507+
* NOTE: This whole block can be removed without breaking anything */
508+
Py_ssize_t noveralloc = n_merges + nkwds;
509+
if (stack != small_stack && noveralloc > 6 && noveralloc * 10 > init_stack_size) {
509510
tmp_stack = PyMem_Realloc(stack, (tot_nargskw - n_merges) * sizeof(PyObject *));
510511
if (tmp_stack == NULL) {
511512
Py_DECREF(tot_kwnames);

0 commit comments

Comments
 (0)