STINNER Victor added the comment:

Copy of msg273365 from the issue #27128:

Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer)        Date: 
2016-08-22 12:29

The problem is that passing keyword arguments as a dict is not the most 
efficient way due to an overhead of creating a dict. For now keyword arguments 
are pushed on the stack as interlaced array of keyword names and values. 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). Therefore we will 
be forced either to change the signature of _PyObject_FastCall() and the 
meaning of METH_FASTCALL, or add new _PyObject_FastCallKw() and METH_FASTCALLKW 
for support fast passing keyword arguments. Or may be add yet 
_PyObject_FastCallNoKw() for faster passing only positional arguments without 
an overhead of _PyObject_FastCall(). And make older _PyObject_FastCall() and 
METH_FASTCAL
 L obsolete.

There is yet one possibility. Argument Clinic can generate a dict that maps 
keyword argument names to indices of arguments and tie it to a function. 
External code should map names to indices using this dictionary and pass 
arguments as just a continuous array to function with METH_FASTCALL (raising an 
error if some argument is passed as positional and keyword, or if keyword-only 
argument is passed as positional, etc). In that case the kwargs parameter of 
_PyObject_FastCall() becomes obsolete too.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27809>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to