You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Argument Clinic: inline the parsing code of optional groups #155373
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.
Hi, I'd like to take a look at this issue and investigate a possible implementation. I'll first trace the current optional-group parsing/code generation and see how the existing converter machinery can be reused. If there are no concerns, I'd be happy to work on this.
Activity
Sumitha007 commentedon Aug 8, 2026
Hi, I'd like to take a look at this issue and investigate a possible implementation. I'll first trace the current optional-group parsing/code generation and see how the existing converter machinery can be reused. If there are no concerns, I'd be happy to work on this.
gh-155373: Inline the parsing code of optional groups in Argument Cli…
pythongh-155373: Inline the parsing code of optional groups in Argume…