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.
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 3410dfe..1675102 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -2009,7 +2009,7 @@
args = PyTuple_Pack(1, dd->default_factory);
if (args == NULL)
return NULL;
- items = _PyObject_CallMethodId((PyObject *)dd, &PyId_items, "()");
+ items = _PyObject_CallMethodId((PyObject *)dd, &PyId_items, NULL);
if (items == NULL) {
Py_DECREF(args);
return NULL;
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index 7e95af7..b48dc2d 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -1378,7 +1378,7 @@
if (time != NULL) {
_Py_IDENTIFIER(time);
- result = _PyObject_CallMethodId(time, &PyId_time, "()");
+ result = _PyObject_CallMethodId(time, &PyId_time, NULL);
Py_DECREF(time);
}
return result;
@@ -2703,7 +2703,7 @@
static PyObject *
date_str(PyDateTime_Date *self)
{
- return _PyObject_CallMethodId((PyObject *)self, &PyId_isoformat, "()");
+ return _PyObject_CallMethodId((PyObject *)self, &PyId_isoformat, NULL);
}
@@ -2729,7 +2729,7 @@
&format))
return NULL;
- tuple = _PyObject_CallMethodId((PyObject *)self, &PyId_timetuple, "()");
+ tuple = _PyObject_CallMethodId((PyObject *)self, &PyId_timetuple, NULL);
if (tuple == NULL)
return NULL;
result = wrap_strftime((PyObject *)self, format, tuple,
@@ -3675,7 +3675,7 @@
static PyObject *
time_str(PyDateTime_Time *self)
{
- return _PyObject_CallMethodId((PyObject *)self, &PyId_isoformat, "()");
+ return _PyObject_CallMethodId((PyObject *)self, &PyId_isoformat, NULL);
}
static PyObject *
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index a8d414e..eae3394 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -2873,7 +2873,7 @@
} else {
_Py_IDENTIFIER(items);
- items = _PyObject_CallMethodId(obj, &PyId_items, "()");
+ items = _PyObject_CallMethodId(obj, &PyId_items, NULL);
if (items == NULL)
goto error;
iter = PyObject_GetIter(items);