Optional groups are the last parsing method in Argument Clinic which still calls the runtime parser: it generates one PyArg_ParseTuple() call per number of arguments, in a big switch.
The code of the converters can be inlined, as in all other methods, with every argument parsed once. For _curses.window.addch([y, x,] ch, [attr]) the four PyArg_ParseTuple() calls become:
if (nargs >= 3) {
y = PyLong_AsInt(args[0]);
...
offset += 2;
group_left_1 = 1;
}
ch = args[offset];
if (nargs == 2 || nargs == 4) {
if (!attr_converter(args[nargs - 1], &attr)) {
goto exit;
}
group_right_1 = 1;
}
This also allows using the fastcall convention, except for constructors and other functions which need a tuple.
Errors for a wrong type of an argument become the same as in other functions, because they are now reported by the converter.
Linked PRs
Optional groups are the last parsing method in Argument Clinic which still calls the runtime parser: it generates one
PyArg_ParseTuple()call per number of arguments, in a big switch.The code of the converters can be inlined, as in all other methods, with every argument parsed once. For
_curses.window.addch([y, x,] ch, [attr])the fourPyArg_ParseTuple()calls become:This also allows using the fastcall convention, except for constructors and other functions which need a tuple.
Errors for a wrong type of an argument become the same as in other functions, because they are now reported by the converter.
Linked PRs