diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-01-11 16:01:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-11 16:01:42 (GMT) |
commit | 2a39d251f07d4c620e3b9a1848e3d1eb3067be64 (patch) | |
tree | 23c1e8e63e57945fab6127d31800b7578795e14b /Modules/clinic/_sre.c.h | |
parent | 4fa9591025b6a098f3d6402e5413ee6740ede6c5 (diff) | |
download | cpython-2a39d251f07d4c620e3b9a1848e3d1eb3067be64.zip cpython-2a39d251f07d4c620e3b9a1848e3d1eb3067be64.tar.gz cpython-2a39d251f07d4c620e3b9a1848e3d1eb3067be64.tar.bz2 |
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.
Diffstat (limited to 'Modules/clinic/_sre.c.h')
-rw-r--r-- | Modules/clinic/_sre.c.h | 29 |
1 files changed, 19 insertions, 10 deletions
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 @@ _sre_SRE_Match_start(MatchObject *self, PyObject *const *args, Py_ssize_t nargs) 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 @@ _sre_SRE_Match_end(MatchObject *self, PyObject *const *args, Py_ssize_t nargs) 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 @@ _sre_SRE_Match_span(MatchObject *self, PyObject *const *args, Py_ssize_t nargs) 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 @@ _sre_SRE_Scanner_search(ScannerObject *self, PyObject *Py_UNUSED(ignored)) { return _sre_SRE_Scanner_search_impl(self); } -/*[clinic end generated code: output=7992634045212b26 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=8d19359d6a4a3a7e input=a9049054013a1b77]*/ |