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/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]*/