STINNER Victor added the comment:

> Proposed patch renames METH_FASTCALL to METH_FASTCALL|METH_KEYWORDS and makes 
> bare METH_FASTCALL be used for functions with positional-only parameters.

While I tried to keep everything related to FASTCALL private, it seems like 
Cython uses some FASTCALL features. I don't know which ones exactly. Well, if 
only one project in the world uses FASTCALL, we can help them to support such 
backward incompatible change ;-)


> This eliminates small cost that these functions pay for handling empty 
> keywords: calling _PyStack_UnpackDict() and _PyArg_NoStackKeywords(), passing 
> kwnames.

My idea when I designed FASTCALL was to move code to parse arguments in the 
function body rather than in _PyCFunction_FastCallKeywords(), and to have a 
single calling function METH_FASTCALL, rather than two (METH_FASTCALL and 
METH_FASTCALL|METH_KEYWORDS).

The long term plan is also to support passing arguments by keyword in more 
functions. IMHO many functions don't accept keywords for technical reasons, but 
once we converted a module, function or type to Argument Clinic, it becomes 
trivial to accept keywords. If most functions accept keywords, I'm not sure 
that having a special case for positional-only is still worth it. But this plan 
was before I had discussions on supporting keywords in unicode methods. In 
fact, it's deliberate to not accept keywords in many functions or methods.

Well, when I see your patch, I see that it removes a lot of code. So it's 
likely to be a good idea :-)


> This also can slightly reduce stack consumption.

You mean the removal of the "PyObject *kwnames" for METH_FASTCALL (positional 
arguments only)? Do you have an idea of the stack usage? Try maybe 
testcapi_stacksize.patch of the issue #28870? It would help to take a decision 
on this change.

----------

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

Reply via email to