diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-08-19 22:44:42 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-08-19 22:44:42 (GMT) |
commit | df142fdc4bfc3816ad36b82a65e335757e011991 (patch) | |
tree | 2b544f6f8e029583f9248391ef8f39ac41ca7aea /Python | |
parent | 9def0901e23c6d655f28b7e5711874033b5ff5bd (diff) | |
download | cpython-df142fdc4bfc3816ad36b82a65e335757e011991.zip cpython-df142fdc4bfc3816ad36b82a65e335757e011991.tar.gz cpython-df142fdc4bfc3816ad36b82a65e335757e011991.tar.bz2 |
import_name() now uses fast call
Issue #27128: import_name() now calls _PyObject_FastCall() to avoid the
creation of a temporary tuple.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 905859e..d16e932 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -5247,7 +5247,8 @@ static PyObject * import_name(PyFrameObject *f, PyObject *name, PyObject *fromlist, PyObject *level) { _Py_IDENTIFIER(__import__); - PyObject *import_func, *args, *res; + PyObject *import_func, *res; + PyObject* stack[5]; import_func = _PyDict_GetItemId(f->f_builtins, &PyId___import__); if (import_func == NULL) { @@ -5271,18 +5272,13 @@ import_name(PyFrameObject *f, PyObject *name, PyObject *fromlist, PyObject *leve } Py_INCREF(import_func); - args = PyTuple_Pack(5, - name, - f->f_globals, - f->f_locals == NULL ? Py_None : f->f_locals, - fromlist, - level); - if (args == NULL) { - Py_DECREF(import_func); - return NULL; - } - res = PyEval_CallObject(import_func, args); - Py_DECREF(args); + + stack[0] = name; + stack[1] = f->f_globals; + stack[2] = f->f_locals == NULL ? Py_None : f->f_locals; + stack[3] = fromlist; + stack[4] = level; + res = _PyObject_FastCall(import_func, stack, 5, NULL); Py_DECREF(import_func); return res; } |