mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Use _PyObject_CallMethodIdObjArgs()
Issue #28915: Replace _PyObject_CallMethodId() with _PyObject_CallMethodIdObjArgs() in various modules when the format string was only made of "O" formats, PyObject* arguments. _PyObject_CallMethodIdObjArgs() avoids the creation of a temporary tuple and doesn't have to parse a format string.
This commit is contained in:
parent
61bdb0d319
commit
55ba38a480
6 changed files with 9 additions and 9 deletions
|
@ -4571,8 +4571,8 @@ find_class(UnpicklerObject *self, PyObject *module_name, PyObject *global_name)
|
||||||
{
|
{
|
||||||
_Py_IDENTIFIER(find_class);
|
_Py_IDENTIFIER(find_class);
|
||||||
|
|
||||||
return _PyObject_CallMethodId((PyObject *)self, &PyId_find_class, "OO",
|
return _PyObject_CallMethodIdObjArgs((PyObject *)self, &PyId_find_class,
|
||||||
module_name, global_name);
|
module_name, global_name, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Py_ssize_t
|
static Py_ssize_t
|
||||||
|
@ -5184,7 +5184,7 @@ instantiate(PyObject *cls, PyObject *args)
|
||||||
else {
|
else {
|
||||||
_Py_IDENTIFIER(__new__);
|
_Py_IDENTIFIER(__new__);
|
||||||
|
|
||||||
result = _PyObject_CallMethodId(cls, &PyId___new__, "O", cls);
|
result = _PyObject_CallMethodIdObjArgs(cls, &PyId___new__, cls, NULL);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1445,7 +1445,7 @@ array_array_tofile(arrayobject *self, PyObject *f)
|
||||||
bytes = PyBytes_FromStringAndSize(ptr, size);
|
bytes = PyBytes_FromStringAndSize(ptr, size);
|
||||||
if (bytes == NULL)
|
if (bytes == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
res = _PyObject_CallMethodId(f, &PyId_write, "O", bytes);
|
res = _PyObject_CallMethodIdObjArgs(f, &PyId_write, bytes, NULL);
|
||||||
Py_DECREF(bytes);
|
Py_DECREF(bytes);
|
||||||
if (res == NULL)
|
if (res == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -1611,7 +1611,7 @@ mbstreamwriter_iwrite(MultibyteStreamWriterObject *self,
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
wr = _PyObject_CallMethodId(self->stream, &PyId_write, "O", str);
|
wr = _PyObject_CallMethodIdObjArgs(self->stream, &PyId_write, str, NULL);
|
||||||
Py_DECREF(str);
|
Py_DECREF(str);
|
||||||
if (wr == NULL)
|
if (wr == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1702,7 +1702,7 @@ _multibytecodec_MultibyteStreamWriter_reset_impl(MultibyteStreamWriterObject *se
|
||||||
if (PyBytes_Size(pwrt) > 0) {
|
if (PyBytes_Size(pwrt) > 0) {
|
||||||
PyObject *wr;
|
PyObject *wr;
|
||||||
|
|
||||||
wr = _PyObject_CallMethodId(self->stream, &PyId_write, "O", pwrt);
|
wr = _PyObject_CallMethodIdObjArgs(self->stream, &PyId_write, pwrt);
|
||||||
if (wr == NULL) {
|
if (wr == NULL) {
|
||||||
Py_DECREF(pwrt);
|
Py_DECREF(pwrt);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -26,7 +26,7 @@ check_matched(PyObject *obj, PyObject *arg)
|
||||||
|
|
||||||
if (obj == Py_None)
|
if (obj == Py_None)
|
||||||
return 1;
|
return 1;
|
||||||
result = _PyObject_CallMethodId(obj, &PyId_match, "O", arg);
|
result = _PyObject_CallMethodIdObjArgs(obj, &PyId_match, arg, NULL);
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
|
@ -1705,7 +1705,7 @@ PyImport_ReloadModule(PyObject *m)
|
||||||
Py_INCREF(imp);
|
Py_INCREF(imp);
|
||||||
}
|
}
|
||||||
|
|
||||||
reloaded_module = _PyObject_CallMethodId(imp, &PyId_reload, "O", m);
|
reloaded_module = _PyObject_CallMethodIdObjArgs(imp, &PyId_reload, m, NULL);
|
||||||
Py_DECREF(imp);
|
Py_DECREF(imp);
|
||||||
return reloaded_module;
|
return reloaded_module;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1649,7 +1649,7 @@ marshal_dump(PyObject *self, PyObject *args)
|
||||||
s = PyMarshal_WriteObjectToString(x, version);
|
s = PyMarshal_WriteObjectToString(x, version);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
res = _PyObject_CallMethodId(f, &PyId_write, "O", s);
|
res = _PyObject_CallMethodIdObjArgs(f, &PyId_write, s, NULL);
|
||||||
Py_DECREF(s);
|
Py_DECREF(s);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue