Author vstinner
Recipients scoder, serhiy.storchaka, vstinner
Date 2016-08-22.22:44:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1471905864.17.0.99232719056.issue27830@psf.upfronthosting.co.za>
In-reply-to
Content
In the issue #27809, I added support for keyword arguments to the function _PyObject_FastCallDict() (previously called _PyObject_FastCall). Keyword arguments are passed as a Python dictionary (dict).

_PyObject_FastCallDict() is efficient when keyword arguments are not used. But when keyword arguments are used, the creation of a temporary dictionary to pass keyword arguments can defeat the "fastcall" optimization for positional arguments.

See Serhiy Storchaka's comment:
http://bugs.python.org/issue27809#msg273367

Extract: "It may be more efficient to push values and names as continuous arrays (issue27213). PyArg_ParseTupleAndKeywords() accepts a tuple and a dict, but private function _PyArg_ParseTupleAndKeywordsFast() (issue27574) can be changed to accept positional and keyword arguments as continuous arrays: (int nargs, PyObject **args, int nkwargs, PyObject **kwnames, PyObject **kwargs)."

And Stefan Behnel's comment:
http://bugs.python.org/issue27809#msg273391

Serhiy proposed to pass keyword arguments as (key, value) pairs in C array. We can probably use the simple "stack" format used in Python/ceval.c:

   PyObject* _PyObject_FastCallKeywords(PyObject *func, PyObject **stack, int nargs, int nkwargs)

where nargs is number of positional arguments at the beginning of stack, and nkwargs is the number of (key, value) pairs at the end of stack.

This function would be the fundation for a new C calling convention: METH_FASTCALL, see the issue #27810.
History
Date User Action Args
2016-08-22 22:44:24vstinnersetrecipients: + vstinner, scoder, serhiy.storchaka
2016-08-22 22:44:24vstinnersetmessageid: <1471905864.17.0.99232719056.issue27830@psf.upfronthosting.co.za>
2016-08-22 22:44:24vstinnerlinkissue27830 messages
2016-08-22 22:44:24vstinnercreate