Serhiy Storchaka <[email protected]> added the comment:
I thought about this variant. The problem is that you need to scan the format
string to the end to determine whether arguments following $ are optional or
not. This adds performance penalty for all existing uses of
PyArg_ParseTupleAndKeywords() with $. Your PR changes the current behavior, and
this is unacceptable too, because it can lead to crashes and other errors in
existing code.
It is possible to add this feature without breakage and performance loss. Just
allow $ to be used twice, for required and optional arguments. Then
PyArg_ParseTupleAndKeywords(args, kwds, "O$O|O$O", kwlist, &a, &c, &b, &d)
will define four parameters in the following order: required
positional-or-keyword, required keyword-only, optional positional-or-keyword,
optional keyword-only.
My doubts are that this order is different from the order of parameters as
defined in Python functions: required positional-or-keyword, optional
positional-or-keyword, required keyword-only, optional keyword-only. I afraid
this can cause confusions.
Although, the first order (all required parameters are first) is more efficient
for processing. So perhaps for compatibility, performance, and the simplicity
of the implementation we will accept it.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue34235>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com