Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 78da82b

Browse files
committed
call_trampoline() now uses fast call
Issue #27128.
1 parent 71cb64a commit 78da82b

1 file changed

Lines changed: 10 additions & 19 deletions

File tree

Python/sysmodule.c

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -368,34 +368,25 @@ static PyObject *
368368
call_trampoline(PyObject* callback,
369369
PyFrameObject *frame, int what, PyObject *arg)
370370
{
371-
PyObject *args;
372-
PyObject *whatstr;
373371
PyObject *result;
372+
PyObject *stack[3];
374373

375-
args = PyTuple_New(3);
376-
if (args == NULL)
377-
return NULL;
378-
if (PyFrame_FastToLocalsWithError(frame) < 0)
374+
if (PyFrame_FastToLocalsWithError(frame) < 0) {
379375
return NULL;
376+
}
380377

381-
Py_INCREF(frame);
382-
whatstr = whatstrings[what];
383-
Py_INCREF(whatstr);
384-
if (arg == NULL)
385-
arg = Py_None;
386-
Py_INCREF(arg);
387-
PyTuple_SET_ITEM(args, 0, (PyObject *)frame);
388-
PyTuple_SET_ITEM(args, 1, whatstr);
389-
PyTuple_SET_ITEM(args, 2, arg);
378+
stack[0] = (PyObject *)frame;
379+
stack[1] = whatstrings[what];
380+
stack[2] = (arg != NULL) ? arg : Py_None;
390381

391382
/* call the Python-level function */
392-
result = PyEval_CallObject(callback, args);
383+
result = _PyObject_FastCall(callback, stack, 3, NULL);
384+
393385
PyFrame_LocalsToFast(frame, 1);
394-
if (result == NULL)
386+
if (result == NULL) {
395387
PyTraceBack_Here(frame);
388+
}
396389

397-
/* cleanup */
398-
Py_DECREF(args);
399390
return result;
400391
}
401392

0 commit comments

Comments
 (0)