mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
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.
This commit is contained in:
parent
8bf08ee45b
commit
2ff58a24e8
12 changed files with 51 additions and 17 deletions
|
@ -141,6 +141,12 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
|
||||
/* Call a callable Python object without any arguments */
|
||||
PyAPI_FUNC(PyObject *) PyObject_CallNoArgs(PyObject *func);
|
||||
#endif
|
||||
|
||||
|
||||
/* Call a callable Python object 'callable' with arguments given by the
|
||||
tuple 'args' and keywords arguments given by the dictionary 'kwargs'.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue