changeset: 105547:b29c719d5992 user: Victor Stinner date: Fri Dec 09 14:24:02 2016 +0100 files: Modules/_asynciomodule.c description: Use _PyObject_CallMethodIdObjArgs() in _asyncio Issue #28915: Replace _PyObject_CallMethodId() with _PyObject_CallMethodIdObjArgs() 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. diff -r 39bed12135c1 -r b29c719d5992 Modules/_asynciomodule.c --- a/Modules/_asynciomodule.c Fri Dec 09 12:29:18 2016 +0100 +++ b/Modules/_asynciomodule.c Fri Dec 09 14:24:02 2016 +0100 @@ -118,8 +118,8 @@ PyObject *handle = NULL; PyObject *cb = PyList_GET_ITEM(iters, i); - handle = _PyObject_CallMethodId( - fut->fut_loop, &PyId_call_soon, "OO", cb, fut, NULL); + handle = _PyObject_CallMethodIdObjArgs(fut->fut_loop, &PyId_call_soon, + cb, fut, NULL); if (handle == NULL) { Py_DECREF(iters); @@ -283,8 +283,9 @@ future_add_done_callback(FutureObj *fut, PyObject *arg) { if (fut->fut_state != STATE_PENDING) { - PyObject *handle = _PyObject_CallMethodId( - fut->fut_loop, &PyId_call_soon, "OO", arg, fut, NULL); + PyObject *handle = _PyObject_CallMethodIdObjArgs(fut->fut_loop, + &PyId_call_soon, + arg, fut, NULL); if (handle == NULL) { return NULL; @@ -1327,7 +1328,7 @@ return -1; } - res = _PyObject_CallMethodId(all_tasks, &PyId_add, "O", self, NULL); + res = _PyObject_CallMethodIdObjArgs(all_tasks, &PyId_add, self, NULL); if (res == NULL) { return -1; } @@ -1838,8 +1839,8 @@ } else { /* `task` is a subclass of Task */ - return _PyObject_CallMethodId( - (PyObject*)task, &PyId__wakeup, "O", fut, NULL); + return _PyObject_CallMethodIdObjArgs((PyObject*)task, &PyId__wakeup, + fut, NULL); } } @@ -1854,8 +1855,8 @@ if (arg == NULL) { arg = Py_None; } - return _PyObject_CallMethodId( - (PyObject*)task, &PyId__step, "O", arg, NULL); + return _PyObject_CallMethodIdObjArgs((PyObject*)task, &PyId__step, + arg, NULL); } } @@ -1869,8 +1870,8 @@ return -1; } - handle = _PyObject_CallMethodId( - task->task_loop, &PyId_call_soon, "O", cb, NULL); + handle = _PyObject_CallMethodIdObjArgs(task->task_loop, &PyId_call_soon, + cb, NULL); Py_DECREF(cb); if (handle == NULL) { return -1; @@ -1965,13 +1966,13 @@ result = _PyGen_Send((PyGenObject*)coro, Py_None); } else { - result = _PyObject_CallMethodIdObjArgs( - coro, &PyId_send, Py_None, NULL); + result = _PyObject_CallMethodIdObjArgs(coro, &PyId_send, + Py_None, NULL); } } else { - result = _PyObject_CallMethodIdObjArgs( - coro, &PyId_throw, exc, NULL); + result = _PyObject_CallMethodIdObjArgs(coro, &PyId_throw, + exc, NULL); if (clear_exc) { /* We created 'exc' during this call */ Py_CLEAR(exc); @@ -2135,8 +2136,9 @@ if (wrapper == NULL) { goto fail; } - res = _PyObject_CallMethodId( - result, &PyId_add_done_callback, "O", wrapper, NULL); + res = _PyObject_CallMethodIdObjArgs(result, + &PyId_add_done_callback, + wrapper, NULL); Py_DECREF(wrapper); if (res == NULL) { goto fail;