bpo-35582: Argument Clinic: Optimize the "all boring objects" case. (GH-11520)
Use _PyArg_CheckPositional() and inlined code instead of
PyArg_UnpackTuple() and _PyArg_UnpackStack() if all parameters
are positional and use the "object" converter.
diff --git a/Python/clinic/sysmodule.c.h b/Python/clinic/sysmodule.c.h
index 7370ab5..fc9794b 100644
--- a/Python/clinic/sysmodule.c.h
+++ b/Python/clinic/sysmodule.c.h
@@ -32,11 +32,12 @@
PyObject *value;
PyObject *traceback;
- if (!_PyArg_UnpackStack(args, nargs, "excepthook",
- 3, 3,
- &exctype, &value, &traceback)) {
+ if (!_PyArg_CheckPositional("excepthook", nargs, 3, 3)) {
goto exit;
}
+ exctype = args[0];
+ value = args[1];
+ traceback = args[2];
return_value = sys_excepthook_impl(module, exctype, value, traceback);
exit:
@@ -87,11 +88,14 @@
PyObject *return_value = NULL;
PyObject *status = NULL;
- if (!_PyArg_UnpackStack(args, nargs, "exit",
- 0, 1,
- &status)) {
+ if (!_PyArg_CheckPositional("exit", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ status = args[0];
+skip_optional:
return_value = sys_exit_impl(module, status);
exit:
@@ -1046,4 +1050,4 @@
#ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
#define SYS_GETANDROIDAPILEVEL_METHODDEF
#endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
-/*[clinic end generated code: output=6a5202e5bfe5e6bd input=a9049054013a1b77]*/
+/*[clinic end generated code: output=109787af3401cd27 input=a9049054013a1b77]*/