mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
Avoid inefficient way to call functions without argument
Don't pass "()" format to PyObject_CallXXX() to call a function without argument: pass NULL as the format string instead. It avoids to have to parse a string to produce 0 argument.
This commit is contained in:
parent
ca08301ae0
commit
ad8c83ad6b
5 changed files with 11 additions and 11 deletions
|
@ -5758,7 +5758,7 @@ static PyObject * \
|
|||
FUNCNAME(PyObject *self) \
|
||||
{ \
|
||||
_Py_static_string(id, OPSTR); \
|
||||
return call_method(self, &id, "()"); \
|
||||
return call_method(self, &id, NULL); \
|
||||
}
|
||||
|
||||
#define SLOT1(FUNCNAME, OPSTR, ARG1TYPE, ARGCODES) \
|
||||
|
@ -5851,7 +5851,7 @@ FUNCNAME(PyObject *self, ARG1TYPE arg1, ARG2TYPE arg2) \
|
|||
static Py_ssize_t
|
||||
slot_sq_length(PyObject *self)
|
||||
{
|
||||
PyObject *res = call_method(self, &PyId___len__, "()");
|
||||
PyObject *res = call_method(self, &PyId___len__, NULL);
|
||||
Py_ssize_t len;
|
||||
|
||||
if (res == NULL)
|
||||
|
@ -6065,7 +6065,7 @@ static PyObject *
|
|||
slot_nb_index(PyObject *self)
|
||||
{
|
||||
_Py_IDENTIFIER(__index__);
|
||||
return call_method(self, &PyId___index__, "()");
|
||||
return call_method(self, &PyId___index__, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -6351,7 +6351,7 @@ static PyObject *
|
|||
slot_tp_iternext(PyObject *self)
|
||||
{
|
||||
_Py_IDENTIFIER(__next__);
|
||||
return call_method(self, &PyId___next__, "()");
|
||||
return call_method(self, &PyId___next__, NULL);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue