This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients larry, msullivan, serhiy.storchaka
Date 2019-02-15.08:29:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1550219362.36.0.100998694698.issue34235@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-02-15 08:29:22serhiy.storchakasetrecipients: + serhiy.storchaka, larry, msullivan
2019-02-15 08:29:22serhiy.storchakasetmessageid: <1550219362.36.0.100998694698.issue34235@roundup.psfhosted.org>
2019-02-15 08:29:22serhiy.storchakalinkissue34235 messages
2019-02-15 08:29:22serhiy.storchakacreate