changeset: 105539:67302e6caa29 user: Victor Stinner date: Fri Dec 09 00:36:19 2016 +0100 files: Modules/_io/textio.c Objects/descrobject.c Python/sysmodule.c description: Use _PyObject_CallMethodIdObjArgs() Issue #28915: Replace _PyObject_CallMethodId() with _PyObject_CallMethodIdObjArgs() when the format string only use the format 'O' for objects, like "(O)". _PyObject_CallMethodIdObjArgs() avoids the code to parse a format string and avoids the creation of a temporary tuple. diff -r b9eb35435178 -r 67302e6caa29 Modules/_io/textio.c --- a/Modules/_io/textio.c Fri Dec 09 00:33:39 2016 +0100 +++ b/Modules/_io/textio.c Fri Dec 09 00:36:19 2016 +0100 @@ -2435,7 +2435,7 @@ } finally: - res = _PyObject_CallMethodId(self->decoder, &PyId_setstate, "(O)", saved_state); + res = _PyObject_CallMethodIdObjArgs(self->decoder, &PyId_setstate, saved_state, NULL); Py_DECREF(saved_state); if (res == NULL) return NULL; @@ -2449,7 +2449,7 @@ if (saved_state) { PyObject *type, *value, *traceback; PyErr_Fetch(&type, &value, &traceback); - res = _PyObject_CallMethodId(self->decoder, &PyId_setstate, "(O)", saved_state); + res = _PyObject_CallMethodIdObjArgs(self->decoder, &PyId_setstate, saved_state, NULL); _PyErr_ChainExceptions(type, value, traceback); Py_DECREF(saved_state); Py_XDECREF(res); diff -r b9eb35435178 -r 67302e6caa29 Objects/descrobject.c --- a/Objects/descrobject.c Fri Dec 09 00:33:39 2016 +0100 +++ b/Objects/descrobject.c Fri Dec 09 00:36:19 2016 +0100 @@ -804,7 +804,8 @@ if (!PyArg_UnpackTuple(args, "get", 1, 2, &key, &def)) return NULL; - return _PyObject_CallMethodId(pp->mapping, &PyId_get, "(OO)", key, def); + return _PyObject_CallMethodIdObjArgs(pp->mapping, &PyId_get, + key, def, NULL); } static PyObject * diff -r b9eb35435178 -r 67302e6caa29 Python/sysmodule.c --- a/Python/sysmodule.c Fri Dec 09 00:33:39 2016 +0100 +++ b/Python/sysmodule.c Fri Dec 09 00:36:19 2016 +0100 @@ -130,7 +130,7 @@ buffer = _PyObject_GetAttrId(outf, &PyId_buffer); if (buffer) { - result = _PyObject_CallMethodId(buffer, &PyId_write, "(O)", encoded); + result = _PyObject_CallMethodIdObjArgs(buffer, &PyId_write, encoded, NULL); Py_DECREF(buffer); Py_DECREF(encoded); if (result == NULL)