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/Modules/clinic/_sre.c.h b/Modules/clinic/_sre.c.h
index e8a3665..e5bb32f 100644
--- a/Modules/clinic/_sre.c.h
+++ b/Modules/clinic/_sre.c.h
@@ -653,11 +653,14 @@
PyObject *group = NULL;
Py_ssize_t _return_value;
- if (!_PyArg_UnpackStack(args, nargs, "start",
- 0, 1,
- &group)) {
+ if (!_PyArg_CheckPositional("start", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ group = args[0];
+skip_optional:
_return_value = _sre_SRE_Match_start_impl(self, group);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
@@ -687,11 +690,14 @@
PyObject *group = NULL;
Py_ssize_t _return_value;
- if (!_PyArg_UnpackStack(args, nargs, "end",
- 0, 1,
- &group)) {
+ if (!_PyArg_CheckPositional("end", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ group = args[0];
+skip_optional:
_return_value = _sre_SRE_Match_end_impl(self, group);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
@@ -720,11 +726,14 @@
PyObject *return_value = NULL;
PyObject *group = NULL;
- if (!_PyArg_UnpackStack(args, nargs, "span",
- 0, 1,
- &group)) {
+ if (!_PyArg_CheckPositional("span", nargs, 0, 1)) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ group = args[0];
+skip_optional:
return_value = _sre_SRE_Match_span_impl(self, group);
exit:
@@ -789,4 +798,4 @@
{
return _sre_SRE_Scanner_search_impl(self);
}
-/*[clinic end generated code: output=7992634045212b26 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=8d19359d6a4a3a7e input=a9049054013a1b77]*/