Skip to content

gh-155373: Inline the parsing code of optional groups in Argument Clinic - #155374

Merged
serhiy-storchaka merged 5 commits into
python:mainfrom
serhiy-storchaka:clinic-groups-inline
Aug 23, 2026
Merged

gh-155373: Inline the parsing code of optional groups in Argument Clinic#155374
serhiy-storchaka merged 5 commits into
python:mainfrom
serhiy-storchaka:clinic-groups-inline

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Instead of one PyArg_ParseTuple() call per number of arguments, generate the inlined code of the converters, as for all other parsing methods. Every argument is parsed once: the groups on the left are parsed if the number of arguments is large enough and shift the following arguments, the required parameters are parsed unconditionally, and the groups on the right depend on the number of arguments.

Such functions now use the fastcall convention, except for constructors and other functions which need a tuple. The hand-written subpad entry in Modules/_cursesmodule.c, which reuses the function generated for _curses.window.subwin, is updated accordingly.

Errors for a wrong type of an argument are now reported by the converter, as in other functions. Where a group can shift the position of an argument, the message does not contain its number, because it differs between the calls.

Converters whose code cannot be inlined (str(encoding=...) for example) keep the current code.

…nt Clinic

Instead of one PyArg_ParseTuple() call per number of arguments, generate
the inlined code of the converters, as for all other parsing methods.
Every argument is parsed once.

Such functions now use the fastcall convention, except for constructors
and other functions which need a tuple.
# Conflicts:
#	Modules/clinic/_ssl.c.h
#	Tools/clinic/libclinic/clanguage.py
#	Tools/clinic/libclinic/parse_args.py
# Conflicts:
#	Modules/clinic/_cursesmodule.c.h
#	Modules/clinic/_ssl.c.h
# Conflicts:
#	Modules/clinic/_cursesmodule.c.h
@serhiy-storchaka
serhiy-storchaka merged commit c1fc445 into python:main Aug 23, 2026
63 checks passed
@serhiy-storchaka
serhiy-storchaka deleted the clinic-groups-inline branch August 23, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant