mirror of
https://github.com/python/cpython.git
synced 2025-10-25 10:44:55 +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
|
|
@ -1528,8 +1528,8 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
|
|||
ntoappend = 1;
|
||||
}
|
||||
else if ((ch = *pin++) == '\0') {
|
||||
/* Null byte follows %, copy only '%'.
|
||||
*
|
||||
/* Null byte follows %, copy only '%'.
|
||||
*
|
||||
* Back the pin up one char so that we catch the null check
|
||||
* the next time through the loop.*/
|
||||
pin--;
|
||||
|
|
@ -1619,7 +1619,7 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
|
|||
usednew += ntoappend;
|
||||
assert(usednew <= totalnew);
|
||||
} /* end while() */
|
||||
|
||||
|
||||
if (_PyBytes_Resize(&newfmt, usednew) < 0)
|
||||
goto Done;
|
||||
{
|
||||
|
|
@ -3607,7 +3607,7 @@ tzinfo_reduce(PyObject *self, PyObject *Py_UNUSED(ignored))
|
|||
|
||||
getinitargs = _PyObject_GetAttrId(self, &PyId___getinitargs__);
|
||||
if (getinitargs != NULL) {
|
||||
args = _PyObject_CallNoArg(getinitargs);
|
||||
args = PyObject_CallNoArgs(getinitargs);
|
||||
Py_DECREF(getinitargs);
|
||||
if (args == NULL) {
|
||||
return NULL;
|
||||
|
|
@ -3624,7 +3624,7 @@ tzinfo_reduce(PyObject *self, PyObject *Py_UNUSED(ignored))
|
|||
|
||||
getstate = _PyObject_GetAttrId(self, &PyId___getstate__);
|
||||
if (getstate != NULL) {
|
||||
state = _PyObject_CallNoArg(getstate);
|
||||
state = PyObject_CallNoArgs(getstate);
|
||||
Py_DECREF(getstate);
|
||||
if (state == NULL) {
|
||||
Py_DECREF(args);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue