From c0ba65035734c4a0ccbdf0ea308a7f4de12527e9 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 30 Jun 2023 02:38:56 +0200 Subject: [PATCH] gh-106023: Remove _PY_FASTCALL_SMALL_STACK constant Remove _PY_FASTCALL_SMALL_STACK constant from the C API: move it to the internal C API (pycore_call.h). --- Include/cpython/abstract.h | 13 ------------- Include/internal/pycore_call.h | 12 ++++++++++++ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h index 2e76ff49a81dd3..d563d1b29ac3b3 100644 --- a/Include/cpython/abstract.h +++ b/Include/cpython/abstract.h @@ -2,19 +2,6 @@ # error "this header file must not be included directly" #endif -/* === Object Protocol ================================================== */ - -/* Suggested size (number of positional arguments) for arrays of PyObject* - allocated on a C stack to avoid allocating memory on the heap memory. Such - array is used to pass positional arguments to call functions of the - PyObject_Vectorcall() family. - - The size is chosen to not abuse the C stack and so limit the risk of stack - overflow. The size is also chosen to allow using the small stack for most - function calls of the Python standard library. On 64-bit CPU, it allocates - 40 bytes on the stack. */ -#define _PY_FASTCALL_SMALL_STACK 5 - /* === Vectorcall protocol (PEP 590) ============================= */ // PyVectorcall_NARGS() is exported as a function for the stable ABI. diff --git a/Include/internal/pycore_call.h b/Include/internal/pycore_call.h index 3caf504a96aa3a..66434cc048cc92 100644 --- a/Include/internal/pycore_call.h +++ b/Include/internal/pycore_call.h @@ -10,6 +10,18 @@ extern "C" { #include "pycore_pystate.h" // _PyThreadState_GET() +/* Suggested size (number of positional arguments) for arrays of PyObject* + allocated on a C stack to avoid allocating memory on the heap memory. Such + array is used to pass positional arguments to call functions of the + PyObject_Vectorcall() family. + + The size is chosen to not abuse the C stack and so limit the risk of stack + overflow. The size is also chosen to allow using the small stack for most + function calls of the Python standard library. On 64-bit CPU, it allocates + 40 bytes on the stack. */ +#define _PY_FASTCALL_SMALL_STACK 5 + + // Export for shared stdlib extensions like the math extension, // function used via inlined _PyObject_VectorcallTstate() function. PyAPI_FUNC(PyObject*) _Py_CheckFunctionResult(