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/itertoolsmodule.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/itertoolsmodule.c.h')
-rw-r--r-- | Modules/clinic/itertoolsmodule.c.h | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/Modules/clinic/itertoolsmodule.c.h b/Modules/clinic/itertoolsmodule.c.h index 9fc429a..bcf4c5f 100644 --- a/Modules/clinic/itertoolsmodule.c.h +++ b/Modules/clinic/itertoolsmodule.c.h @@ -124,11 +124,10 @@ itertools__tee(PyTypeObject *type, PyObject *args, PyObject *kwargs) !_PyArg_NoKeywords("_tee", kwargs)) { goto exit; } - if (!PyArg_UnpackTuple(args, "_tee", - 1, 1, - &iterable)) { + if (!_PyArg_CheckPositional("_tee", PyTuple_GET_SIZE(args), 1, 1)) { goto exit; } + iterable = PyTuple_GET_ITEM(args, 0); return_value = itertools__tee_impl(type, iterable); exit: @@ -204,11 +203,10 @@ itertools_cycle(PyTypeObject *type, PyObject *args, PyObject *kwargs) !_PyArg_NoKeywords("cycle", kwargs)) { goto exit; } - if (!PyArg_UnpackTuple(args, "cycle", - 1, 1, - &iterable)) { + if (!_PyArg_CheckPositional("cycle", PyTuple_GET_SIZE(args), 1, 1)) { goto exit; } + iterable = PyTuple_GET_ITEM(args, 0); return_value = itertools_cycle_impl(type, iterable); exit: @@ -237,11 +235,11 @@ itertools_dropwhile(PyTypeObject *type, PyObject *args, PyObject *kwargs) !_PyArg_NoKeywords("dropwhile", kwargs)) { goto exit; } - if (!PyArg_UnpackTuple(args, "dropwhile", - 2, 2, - &func, &seq)) { + if (!_PyArg_CheckPositional("dropwhile", PyTuple_GET_SIZE(args), 2, 2)) { goto exit; } + func = PyTuple_GET_ITEM(args, 0); + seq = PyTuple_GET_ITEM(args, 1); return_value = itertools_dropwhile_impl(type, func, seq); exit: @@ -268,11 +266,11 @@ itertools_takewhile(PyTypeObject *type, PyObject *args, PyObject *kwargs) !_PyArg_NoKeywords("takewhile", kwargs)) { goto exit; } - if (!PyArg_UnpackTuple(args, "takewhile", - 2, 2, - &func, &seq)) { + if (!_PyArg_CheckPositional("takewhile", PyTuple_GET_SIZE(args), 2, 2)) { goto exit; } + func = PyTuple_GET_ITEM(args, 0); + seq = PyTuple_GET_ITEM(args, 1); return_value = itertools_takewhile_impl(type, func, seq); exit: @@ -299,11 +297,11 @@ itertools_starmap(PyTypeObject *type, PyObject *args, PyObject *kwargs) !_PyArg_NoKeywords("starmap", kwargs)) { goto exit; } - if (!PyArg_UnpackTuple(args, "starmap", - 2, 2, - &func, &seq)) { + if (!_PyArg_CheckPositional("starmap", PyTuple_GET_SIZE(args), 2, 2)) { goto exit; } + func = PyTuple_GET_ITEM(args, 0); + seq = PyTuple_GET_ITEM(args, 1); return_value = itertools_starmap_impl(type, func, seq); exit: @@ -496,11 +494,11 @@ itertools_filterfalse(PyTypeObject *type, PyObject *args, PyObject *kwargs) !_PyArg_NoKeywords("filterfalse", kwargs)) { goto exit; } - if (!PyArg_UnpackTuple(args, "filterfalse", - 2, 2, - &func, &seq)) { + if (!_PyArg_CheckPositional("filterfalse", PyTuple_GET_SIZE(args), 2, 2)) { goto exit; } + func = PyTuple_GET_ITEM(args, 0); + seq = PyTuple_GET_ITEM(args, 1); return_value = itertools_filterfalse_impl(type, func, seq); exit: @@ -542,4 +540,4 @@ itertools_count(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=f289354f54e04c13 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3d0ca69707b60715 input=a9049054013a1b77]*/ |