Skip to content

Commit 424b44f

Browse files
committed
Convert macros to static inline functions
This adds some additional type safety, and (for _PyObject_FastCall) makes the exact argument types explicit. Also, add descriptions in comments
1 parent f4b1224 commit 424b44f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Include/cpython/abstract.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,18 @@ PyAPI_FUNC(PyObject *) _PyObject_FastCallDict(
141141
"tuple" and keyword arguments "dict". "dict" may also be NULL */
142142
PyAPI_FUNC(PyObject *) PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *dict);
143143

144-
#define _PyObject_FastCall(func, args, nargs) \
145-
_PyObject_Vectorcall((func), (args), (nargs), NULL)
144+
/* Same as _PyObject_Vectorcall except without keyword arguments */
145+
static inline PyObject *
146+
_PyObject_FastCall(PyObject *func, PyObject *const *args, Py_ssize_t nargs)
147+
{
148+
return _PyObject_Vectorcall(func, args, (size_t)nargs, NULL);
149+
}
146150

147-
#define _PyObject_CallNoArg(func) \
148-
_PyObject_Vectorcall((func), NULL, 0, NULL)
151+
/* Call a callable without any arguments */
152+
static inline PyObject *
153+
_PyObject_CallNoArg(PyObject *func) {
154+
return _PyObject_Vectorcall(func, NULL, 0, NULL);
155+
}
149156

150157
PyAPI_FUNC(PyObject *) _PyObject_Call_Prepend(
151158
PyObject *callable,

0 commit comments

Comments
 (0)