File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed
numpy/core/src/multiarray Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -71,12 +71,13 @@ npy_forward_method(
71
71
PyObject * callable , PyObject * self ,
72
72
PyObject * const * args , Py_ssize_t len_args , PyObject * kwnames )
73
73
{
74
- PyObject * * new_args ;
74
+ PyObject * args_buffer [NPY_MAXARGS ];
75
+ /* Practically guaranteed NPY_MAXARGS is enough. */
76
+ PyObject * * new_args = args_buffer ;
75
77
76
78
/*
77
- * Unfortunately, `PY_VECTORCALL_ARGUMENTS_OFFSET` seems currently never
78
- * set for methods at this time, so not implementing just modifying
79
- * args[-1] here.
79
+ * `PY_VECTORCALL_ARGUMENTS_OFFSET` seems never set, probably `args[-1]`
80
+ * is always `self` but do not rely on it unless Python documents that.
80
81
*/
81
82
npy_intp len_kwargs = kwnames != NULL ? PyTuple_GET_SIZE (kwnames ) : 0 ;
82
83
size_t original_arg_size = (len_args + len_kwargs ) * sizeof (PyObject * );
@@ -92,10 +93,6 @@ npy_forward_method(
92
93
return PyErr_NoMemory ();
93
94
}
94
95
}
95
- else {
96
- /* Almost guaranteed a stack allocation is enough. */
97
- new_args = alloca (original_arg_size + sizeof (PyObject * ));
98
- }
99
96
100
97
new_args [0 ] = self ;
101
98
memcpy (& new_args [1 ], args , original_arg_size );
You can’t perform that action at this time.
0 commit comments