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/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h
index 2d7c742..a4669f5 100644
--- a/Objects/clinic/bytearrayobject.c.h
+++ b/Objects/clinic/bytearrayobject.c.h
@@ -545,11 +545,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 = bytearray_strip_impl(self, bytes);
exit:
@@ -576,11 +579,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 = bytearray_lstrip_impl(self, bytes);
exit:
@@ -607,11 +613,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 = bytearray_rstrip_impl(self, bytes);
exit:
@@ -815,4 +824,4 @@
{
return bytearray_sizeof_impl(self);
}
-/*[clinic end generated code: output=010e281b823d7df1 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=f4353c27dcb4a13d input=a9049054013a1b77]*/