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/Objects/clinic/bytesobject.c.h b/Objects/clinic/bytesobject.c.h
index 4e754d9..d75bbf1 100644
--- a/Objects/clinic/bytesobject.c.h
+++ b/Objects/clinic/bytesobject.c.h
@@ -203,11 +203,14 @@
PyObject *return_value = NULL;
PyObject *bytes = Py_None;
- if (!_PyArg_UnpackStack(args, nargs, "strip",
- 0, 1,
- &bytes)) {
+ if (!_PyArg_CheckPositional("strip", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ bytes = args[0];
+skip_optional:
return_value = bytes_strip_impl(self, bytes);
exit:
@@ -234,11 +237,14 @@
PyObject *return_value = NULL;
PyObject *bytes = Py_None;
- if (!_PyArg_UnpackStack(args, nargs, "lstrip",
- 0, 1,
- &bytes)) {
+ if (!_PyArg_CheckPositional("lstrip", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ bytes = args[0];
+skip_optional:
return_value = bytes_lstrip_impl(self, bytes);
exit:
@@ -265,11 +271,14 @@
PyObject *return_value = NULL;
PyObject *bytes = Py_None;
- if (!_PyArg_UnpackStack(args, nargs, "rstrip",
- 0, 1,
- &bytes)) {
+ if (!_PyArg_CheckPositional("rstrip", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ bytes = args[0];
+skip_optional:
return_value = bytes_rstrip_impl(self, bytes);
exit:
@@ -559,4 +568,4 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=810c8dfc72520ca4 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=c6621bda84e63e51 input=a9049054013a1b77]*/