[Python-Dev] New calling convention to avoid temporarily tuples when calling functions (original) (raw)

Victor Stinner victor.stinner at gmail.com
Wed Aug 24 18:53:06 EDT 2016


2016-08-22 10:01 GMT+02:00 Victor Stinner <victor.stinner at gmail.com>:

The next step is to support keyword parameters. In fact, it's already supported in all cases except of Python functions: https://bugs.python.org/issue27809

Serhiy Storchaka proposed to use a single C array for positional and keyword arguments. Keyword arguments are passed as (key, value) pairs. I just added this function:

 PyAPI_FUNC(PyObject *) _PyObject_FastCallKeywords(
                            PyObject *func,
                            PyObject **stack,
                            Py_ssize_t nargs,
                            Py_ssize_t nkwargs);

The function is not used yet. Serhiy proposed to enhance the functions to parse arguments to support this format to pass arguments which would allow to avoid the creation of a temporary dictionary in many cases.

I proposed to use this format (instead of (PyObject **stack, Py_ssize_t nargs, PyObject *kwargs)) for a new METH_FASTCALL calling convention for C functions: https://bugs.python.org/issue27810

Victor



More information about the Python-Dev mailing list