There are custom Argument Clinic converters that define format_unit but omit parse_arg. As a result, generation of positional argument parsers is forced to back up from the fastest possible _PyArg_CheckPositional to slower _PyArg_ParseStack-based format strings.
Here is a list of such classes (and fixing PRs except complex cases):
An example of such a converter:
class BOOL_converter(CConverter):
type = 'BOOL'
format_unit = 'i'
class pid_t_converter(CConverter):
type = 'pid_t'
format_unit = '" _Py_PARSE_PID "'
I'm going to teach all of them about low-level generation by replacing manual format_unit definitions with:
- inheritance from a corresponding builtin converter where possible
- and custom
parse_args in other places.
For the example it gives:
class BOOL_converter(int_converter):
type = 'BOOL'
class pid_t_converter(CConverter):
type = 'pid_t'
# Left as a backup for potential complex cases
format_unit = '" _Py_PARSE_PID "'
def parse_arg(self, argname, displayname):
return """
{paramname} = PyLong_AsPid({argname});
if ({paramname} == -1 && PyErr_Occurred()) {{{{
goto exit;
}}}}
""".format(argname=argname, paramname=self.parser_name)
There are custom Argument Clinic converters that define
format_unitbut omitparse_arg. As a result, generation of positional argument parsers is forced to back up from the fastest possible_PyArg_CheckPositionalto slower_PyArg_ParseStack-based format strings.Here is a list of such classes (and fixing PRs except complex cases):
Modules\_multiprocessing\multiprocessing.c (gh-94512: Fix forced arg format in AC-processed multiprocessing #94517)
Modules\_multiprocessing\semaphore.c
Modules\overlapped.c (gh-94512: Fix forced arg format in AC-processed overlapped #94516)
Modules\posixmodule.c (gh-94512: Fix forced arg format in AC-processed
posixmodule.c#122516)Modules\resource.c (gh-94512: Fix forced arg format in AC-processed resource #94515)
PC\msvcrtmodule.c (gh-94512: Fix forced arg format in AC-processed msvcrtmodule #94514)
PC\winreg.c (gh-94512: Fix forced arg format in AC-processed winreg #94513)
An example of such a converter:
I'm going to teach all of them about low-level generation by replacing manual
format_unitdefinitions with:parse_args in other places.For the example it gives: