Repository navigation
Port 23-argument _posixsubprocess.fork_exec to Argument Clinic #94518
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancement
on Jul 2, 2022 Indeed, one reason I've left it a behemoth in the past is that it only has 2-3 call-sites and gained parameters slowly over time. Cleaning this monster up will be good.
One minor concern with argument clinic on this is the C stack space use increase due to the intermediate function calling the implementation with everything as C arguments on the stack. BUT... there is some other long overdue _posixsubprocess refactoring to be done that could alleviate stack use elsewhere (not to be done as part of this issue) in 3.12 that could make up for this change by reducing a similar amount of C stack use. (the internal C call to the child fork exec function which is also a giant messy pile of C args)
Also, the argument clinic generated code is effectively a tail call to the _impl. Ideally compilers see that in optimized builds and effectively inline/merge the two functions instead of wasting time separating them with a calling convention sucking up stack. (No guarantees on that)
If we went an alternate route and constructed a structure with all of the values instead of a giant list of arguments (a namedtuple could make it an easy transition), the C stack overhead from argument clinic would be gone. But so would the nice value type checking boilerplate that argument clinic handles for us. Unless we created our own internal to _posixsubprocess type instead of namedtuple and used argument clinic on its construction and data fill-in APIs instead. That idea could just be overcomplicated. I'll ponder it.
In the meantime, thanks for the PR. I'll get to a review on that soon.
Reacted by Erlend E. Aasland and Oleg Iarygin- added a commit that references this issue
on Jan 14, 2023 - added a commit that references this issue
on Apr 24, 2023 thanks! :)
Reacted by Oleg Iarygin- added 2 commits that reference this issue
on Apr 24, 2023
Currently the function is parsed with the following behemoth:
Conversion will:
METH_FASTCALL+_PyArg_CheckPositional.Linked PRs
_posixsubprocess.fork_execto Argument Clinic #94519group*toextra_group*to avoid confusion #101054