diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2020-12-01 04:42:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-01 04:42:54 (GMT) |
commit | cc061d0e6fb2569efa91531686f75b89e94ec865 (patch) | |
tree | c4c2a24657c2437ff04b6f32677cc70ec8756478 /Modules/clinic | |
parent | 427613f005f0f412d12f0d775d2b609bae0ae1ad (diff) | |
download | cpython-cc061d0e6fb2569efa91531686f75b89e94ec865.zip cpython-cc061d0e6fb2569efa91531686f75b89e94ec865.tar.gz cpython-cc061d0e6fb2569efa91531686f75b89e94ec865.tar.bz2 |
bpo-38200: Add itertools.pairwise() (GH-23549)
Diffstat (limited to 'Modules/clinic')
-rw-r--r-- | Modules/clinic/itertoolsmodule.c.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/Modules/clinic/itertoolsmodule.c.h b/Modules/clinic/itertoolsmodule.c.h index c1192bb..82729ee 100644 --- a/Modules/clinic/itertoolsmodule.c.h +++ b/Modules/clinic/itertoolsmodule.c.h @@ -2,6 +2,37 @@ preserve [clinic start generated code]*/ +PyDoc_STRVAR(pairwise_new__doc__, +"pairwise(iterable, /)\n" +"--\n" +"\n" +"Return an iterator of overlapping pairs taken from the input iterator.\n" +"\n" +" s -> (s0,s1), (s1,s2), (s2, s3), ..."); + +static PyObject * +pairwise_new_impl(PyTypeObject *type, PyObject *iterable); + +static PyObject * +pairwise_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *iterable; + + if ((type == &pairwise_type) && + !_PyArg_NoKeywords("pairwise", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("pairwise", PyTuple_GET_SIZE(args), 1, 1)) { + goto exit; + } + iterable = PyTuple_GET_ITEM(args, 0); + return_value = pairwise_new_impl(type, iterable); + +exit: + return return_value; +} + PyDoc_STRVAR(itertools_groupby__doc__, "groupby(iterable, key=None)\n" "--\n" @@ -627,4 +658,4 @@ skip_optional_pos: exit: return return_value; } -/*[clinic end generated code: output=d7f58dc477814b45 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=889c4afc3b13574f input=a9049054013a1b77]*/ |