[issue27213] Rework CALL_FUNCTION* opcodes

STINNER Victor report at bugs.python.org
Thu Aug 25 18:27:13 EDT 2016


STINNER Victor added the comment:

I'm working on a new calling convention: "fast call".

I already pushed changes implementing first functions:

_PyObject_FastCallDict(PyObject *func, PyObject **stack, Py_ssize_t nargs, PyObject *kwargs)

kwargs is a Python dict, but it can be NULL.

_PyObject_FastCallDict() avoids the creation a temporary tuple when you don't have to pass keyword arguments.

But I'm interested by an evolution to avoid also the creation of a temporary dictionary: issue #27830, "Add _PyObject_FastCallKeywords(): avoid the creation of a temporary dictionary for keyword arguments". This function would be the fundation for a new calling convention for C functions: #27810, "Add METH_FASTCALL: new calling convention for C functions".

I didn't read your patch carefully, but I would like to make sure that your patch would benefit of these APIs to avoid the creation of temporary tuple and/or dict.

"func(*args, key=value)" uses CALL_FUNCTION_EX and so requires to create a temporary dictionary. Maybe it's ok, I don't think that this syntax is commonly used.

"func(*args)" uses CALL_FUNCTION_EX: if args is a tuple, can you confirm that it would be possible to use _PyObject_FastCallDict() and/or _PyObject_FastCallKeywords() to avoid the creation a new temporary tuple?

Hum, I don't think that "func(*args)" can be optimized if args is a list because a list is mutable, we cannot use a direct access to the internal C array of a list.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue27213>
_______________________________________


More information about the Python-bugs-list mailing list