Argument Clinic: inline the parsing code of optional groups #155373
Copy link
Copy link
Closed
Labels
Description
Activity
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.
- addedtype-featureA feature request or enhancementA feature request or enhancement
on Aug 8, 2026 - added a commit that references this issue
on Aug 23, 2026


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