diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-06-17 12:27:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-17 12:27:23 (GMT) |
commit | 2ff58a24e8a1c7e290d025d69ebaea0bbead3b8c (patch) | |
tree | 85d26a4891196105808df38b430c3332d591da13 /Include/cpython | |
parent | 8bf08ee45b7c2341f0d0175b91892843a37c23da (diff) | |
download | cpython-2ff58a24e8a1c7e290d025d69ebaea0bbead3b8c.zip cpython-2ff58a24e8a1c7e290d025d69ebaea0bbead3b8c.tar.gz cpython-2ff58a24e8a1c7e290d025d69ebaea0bbead3b8c.tar.bz2 |
bpo-37194: Add a new public PyObject_CallNoArgs() function (GH-13890)
Add a new public PyObject_CallNoArgs() function to the C API: call a
callable Python object without any arguments.
It is the most efficient way to call a callback without any argument.
On x86-64, for example, PyObject_CallFunctionObjArgs(func, NULL)
allocates 960 bytes on the stack per call, whereas
PyObject_CallNoArgs(func) only allocates 624 bytes per call.
It is excluded from stable ABI 3.8.
Replace private _PyObject_CallNoArg() with public
PyObject_CallNoArgs() in C extensions: _asyncio, _datetime,
_elementtree, _pickle, _tkinter and readline.
Diffstat (limited to 'Include/cpython')
-rw-r--r-- | Include/cpython/abstract.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h index d036912..415f3e1 100644 --- a/Include/cpython/abstract.h +++ b/Include/cpython/abstract.h @@ -144,7 +144,9 @@ _PyObject_FastCall(PyObject *func, PyObject *const *args, Py_ssize_t nargs) return _PyObject_Vectorcall(func, args, (size_t)nargs, NULL); } -/* Call a callable without any arguments */ +/* Call a callable without any arguments + Private static inline function variant of public function + PyObject_CallNoArgs(). */ static inline PyObject * _PyObject_CallNoArg(PyObject *func) { return _PyObject_Vectorcall(func, NULL, 0, NULL); |