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]*/
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]*/
diff --git a/Objects/clinic/dictobject.c.h b/Objects/clinic/dictobject.c.h
index 5db3a42..713781c 100644
--- a/Objects/clinic/dictobject.c.h
+++ b/Objects/clinic/dictobject.c.h
@@ -21,11 +21,15 @@
     PyObject *iterable;
     PyObject *value = Py_None;
 
-    if (!_PyArg_UnpackStack(args, nargs, "fromkeys",
-        1, 2,
-        &iterable, &value)) {
+    if (!_PyArg_CheckPositional("fromkeys", nargs, 1, 2)) {
         goto exit;
     }
+    iterable = args[0];
+    if (nargs < 2) {
+        goto skip_optional;
+    }
+    value = args[1];
+skip_optional:
     return_value = dict_fromkeys_impl(type, iterable, value);
 
 exit:
@@ -60,11 +64,15 @@
     PyObject *key;
     PyObject *default_value = Py_None;
 
-    if (!_PyArg_UnpackStack(args, nargs, "get",
-        1, 2,
-        &key, &default_value)) {
+    if (!_PyArg_CheckPositional("get", nargs, 1, 2)) {
         goto exit;
     }
+    key = args[0];
+    if (nargs < 2) {
+        goto skip_optional;
+    }
+    default_value = args[1];
+skip_optional:
     return_value = dict_get_impl(self, key, default_value);
 
 exit:
@@ -93,11 +101,15 @@
     PyObject *key;
     PyObject *default_value = Py_None;
 
-    if (!_PyArg_UnpackStack(args, nargs, "setdefault",
-        1, 2,
-        &key, &default_value)) {
+    if (!_PyArg_CheckPositional("setdefault", nargs, 1, 2)) {
         goto exit;
     }
+    key = args[0];
+    if (nargs < 2) {
+        goto skip_optional;
+    }
+    default_value = args[1];
+skip_optional:
     return_value = dict_setdefault_impl(self, key, default_value);
 
 exit:
@@ -121,4 +133,4 @@
 {
     return dict___reversed___impl(self);
 }
-/*[clinic end generated code: output=193e08cb8099fe22 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=12c21ce3552d9617 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/enumobject.c.h b/Objects/clinic/enumobject.c.h
index 0f05cf8..27da294 100644
--- a/Objects/clinic/enumobject.c.h
+++ b/Objects/clinic/enumobject.c.h
@@ -58,14 +58,13 @@
         !_PyArg_NoKeywords("reversed", kwargs)) {
         goto exit;
     }
-    if (!PyArg_UnpackTuple(args, "reversed",
-        1, 1,
-        &seq)) {
+    if (!_PyArg_CheckPositional("reversed", PyTuple_GET_SIZE(args), 1, 1)) {
         goto exit;
     }
+    seq = PyTuple_GET_ITEM(args, 0);
     return_value = reversed_new_impl(type, seq);
 
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=9008c36999c57218 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=831cec3db0e987c9 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/floatobject.c.h b/Objects/clinic/floatobject.c.h
index 741ca3b..4251d63 100644
--- a/Objects/clinic/floatobject.c.h
+++ b/Objects/clinic/floatobject.c.h
@@ -58,11 +58,14 @@
     PyObject *return_value = NULL;
     PyObject *o_ndigits = NULL;
 
-    if (!_PyArg_UnpackStack(args, nargs, "__round__",
-        0, 1,
-        &o_ndigits)) {
+    if (!_PyArg_CheckPositional("__round__", nargs, 0, 1)) {
         goto exit;
     }
+    if (nargs < 1) {
+        goto skip_optional;
+    }
+    o_ndigits = args[0];
+skip_optional:
     return_value = float___round___impl(self, o_ndigits);
 
 exit:
@@ -173,11 +176,14 @@
         !_PyArg_NoKeywords("float", kwargs)) {
         goto exit;
     }
-    if (!PyArg_UnpackTuple(args, "float",
-        0, 1,
-        &x)) {
+    if (!_PyArg_CheckPositional("float", PyTuple_GET_SIZE(args), 0, 1)) {
         goto exit;
     }
+    if (PyTuple_GET_SIZE(args) < 1) {
+        goto skip_optional;
+    }
+    x = PyTuple_GET_ITEM(args, 0);
+skip_optional:
     return_value = float_new_impl(type, x);
 
 exit:
@@ -345,4 +351,4 @@
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=2631a60701a8f7d4 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=c183029d87dd41fa input=a9049054013a1b77]*/
diff --git a/Objects/clinic/listobject.c.h b/Objects/clinic/listobject.c.h
index 3617458..447cdef 100644
--- a/Objects/clinic/listobject.c.h
+++ b/Objects/clinic/listobject.c.h
@@ -289,11 +289,14 @@
         !_PyArg_NoKeywords("list", kwargs)) {
         goto exit;
     }
-    if (!PyArg_UnpackTuple(args, "list",
-        0, 1,
-        &iterable)) {
+    if (!_PyArg_CheckPositional("list", PyTuple_GET_SIZE(args), 0, 1)) {
         goto exit;
     }
+    if (PyTuple_GET_SIZE(args) < 1) {
+        goto skip_optional;
+    }
+    iterable = PyTuple_GET_ITEM(args, 0);
+skip_optional:
     return_value = list___init___impl((PyListObject *)self, iterable);
 
 exit:
@@ -335,4 +338,4 @@
 {
     return list___reversed___impl(self);
 }
-/*[clinic end generated code: output=1f641f5aef3f886f input=a9049054013a1b77]*/
+/*[clinic end generated code: output=4a835f9880a72273 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/tupleobject.c.h b/Objects/clinic/tupleobject.c.h
index 0096f0c..fe2fae4 100644
--- a/Objects/clinic/tupleobject.c.h
+++ b/Objects/clinic/tupleobject.c.h
@@ -81,11 +81,14 @@
         !_PyArg_NoKeywords("tuple", kwargs)) {
         goto exit;
     }
-    if (!PyArg_UnpackTuple(args, "tuple",
-        0, 1,
-        &iterable)) {
+    if (!_PyArg_CheckPositional("tuple", PyTuple_GET_SIZE(args), 0, 1)) {
         goto exit;
     }
+    if (PyTuple_GET_SIZE(args) < 1) {
+        goto skip_optional;
+    }
+    iterable = PyTuple_GET_ITEM(args, 0);
+skip_optional:
     return_value = tuple_new_impl(type, iterable);
 
 exit:
@@ -108,4 +111,4 @@
 {
     return tuple___getnewargs___impl(self);
 }
-/*[clinic end generated code: output=5312868473a41cfe input=a9049054013a1b77]*/
+/*[clinic end generated code: output=56fab9b7368aba49 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/unicodeobject.c.h b/Objects/clinic/unicodeobject.c.h
index 21e54f1..3e40a62 100644
--- a/Objects/clinic/unicodeobject.c.h
+++ b/Objects/clinic/unicodeobject.c.h
@@ -546,11 +546,14 @@
     PyObject *return_value = NULL;
     PyObject *chars = Py_None;
 
-    if (!_PyArg_UnpackStack(args, nargs, "strip",
-        0, 1,
-        &chars)) {
+    if (!_PyArg_CheckPositional("strip", nargs, 0, 1)) {
         goto exit;
     }
+    if (nargs < 1) {
+        goto skip_optional;
+    }
+    chars = args[0];
+skip_optional:
     return_value = unicode_strip_impl(self, chars);
 
 exit:
@@ -577,11 +580,14 @@
     PyObject *return_value = NULL;
     PyObject *chars = NULL;
 
-    if (!_PyArg_UnpackStack(args, nargs, "lstrip",
-        0, 1,
-        &chars)) {
+    if (!_PyArg_CheckPositional("lstrip", nargs, 0, 1)) {
         goto exit;
     }
+    if (nargs < 1) {
+        goto skip_optional;
+    }
+    chars = args[0];
+skip_optional:
     return_value = unicode_lstrip_impl(self, chars);
 
 exit:
@@ -608,11 +614,14 @@
     PyObject *return_value = NULL;
     PyObject *chars = NULL;
 
-    if (!_PyArg_UnpackStack(args, nargs, "rstrip",
-        0, 1,
-        &chars)) {
+    if (!_PyArg_CheckPositional("rstrip", nargs, 0, 1)) {
         goto exit;
     }
+    if (nargs < 1) {
+        goto skip_optional;
+    }
+    chars = args[0];
+skip_optional:
     return_value = unicode_rstrip_impl(self, chars);
 
 exit:
@@ -1098,4 +1107,4 @@
 {
     return unicode_sizeof_impl(self);
 }
-/*[clinic end generated code: output=73ad9670e00a2490 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=087ff163a10505ae input=a9049054013a1b77]*/