diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/tools/python3/src/Modules/itertoolsmodule.c | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Modules/itertoolsmodule.c')
-rw-r--r-- | contrib/tools/python3/src/Modules/itertoolsmodule.c | 1008 |
1 files changed, 504 insertions, 504 deletions
diff --git a/contrib/tools/python3/src/Modules/itertoolsmodule.c b/contrib/tools/python3/src/Modules/itertoolsmodule.c index a44c74f98f..bc5382af7e 100644 --- a/contrib/tools/python3/src/Modules/itertoolsmodule.c +++ b/contrib/tools/python3/src/Modules/itertoolsmodule.c @@ -1,54 +1,54 @@ #define PY_SSIZE_T_CLEAN #include "Python.h" -#include "pycore_tupleobject.h" -#include "pycore_object.h" // _PyObject_GC_TRACK() -#include <stddef.h> // offsetof() +#include "pycore_tupleobject.h" +#include "pycore_object.h" // _PyObject_GC_TRACK() +#include <stddef.h> // offsetof() /* Itertools module written and maintained by Raymond D. Hettinger <python@rcn.com> */ -/*[clinic input] -module itertools -class itertools.groupby "groupbyobject *" "&groupby_type" -class itertools._grouper "_grouperobject *" "&_grouper_type" -class itertools.teedataobject "teedataobject *" "&teedataobject_type" -class itertools._tee "teeobject *" "&tee_type" -class itertools.cycle "cycleobject *" "&cycle_type" -class itertools.dropwhile "dropwhileobject *" "&dropwhile_type" -class itertools.takewhile "takewhileobject *" "&takewhile_type" -class itertools.starmap "starmapobject *" "&starmap_type" -class itertools.chain "chainobject *" "&chain_type" -class itertools.combinations "combinationsobject *" "&combinations_type" -class itertools.combinations_with_replacement "cwr_object *" "&cwr_type" -class itertools.permutations "permutationsobject *" "&permutations_type" -class itertools.accumulate "accumulateobject *" "&accumulate_type" -class itertools.compress "compressobject *" "&compress_type" -class itertools.filterfalse "filterfalseobject *" "&filterfalse_type" -class itertools.count "countobject *" "&count_type" -[clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=ea05c93c6d94726a]*/ - -static PyTypeObject groupby_type; -static PyTypeObject _grouper_type; -static PyTypeObject teedataobject_type; -static PyTypeObject tee_type; -static PyTypeObject cycle_type; -static PyTypeObject dropwhile_type; -static PyTypeObject takewhile_type; -static PyTypeObject starmap_type; -static PyTypeObject combinations_type; -static PyTypeObject cwr_type; -static PyTypeObject permutations_type; -static PyTypeObject accumulate_type; -static PyTypeObject compress_type; -static PyTypeObject filterfalse_type; -static PyTypeObject count_type; - -#include "clinic/itertoolsmodule.c.h" - - +/*[clinic input] +module itertools +class itertools.groupby "groupbyobject *" "&groupby_type" +class itertools._grouper "_grouperobject *" "&_grouper_type" +class itertools.teedataobject "teedataobject *" "&teedataobject_type" +class itertools._tee "teeobject *" "&tee_type" +class itertools.cycle "cycleobject *" "&cycle_type" +class itertools.dropwhile "dropwhileobject *" "&dropwhile_type" +class itertools.takewhile "takewhileobject *" "&takewhile_type" +class itertools.starmap "starmapobject *" "&starmap_type" +class itertools.chain "chainobject *" "&chain_type" +class itertools.combinations "combinationsobject *" "&combinations_type" +class itertools.combinations_with_replacement "cwr_object *" "&cwr_type" +class itertools.permutations "permutationsobject *" "&permutations_type" +class itertools.accumulate "accumulateobject *" "&accumulate_type" +class itertools.compress "compressobject *" "&compress_type" +class itertools.filterfalse "filterfalseobject *" "&filterfalse_type" +class itertools.count "countobject *" "&count_type" +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=ea05c93c6d94726a]*/ + +static PyTypeObject groupby_type; +static PyTypeObject _grouper_type; +static PyTypeObject teedataobject_type; +static PyTypeObject tee_type; +static PyTypeObject cycle_type; +static PyTypeObject dropwhile_type; +static PyTypeObject takewhile_type; +static PyTypeObject starmap_type; +static PyTypeObject combinations_type; +static PyTypeObject cwr_type; +static PyTypeObject permutations_type; +static PyTypeObject accumulate_type; +static PyTypeObject compress_type; +static PyTypeObject filterfalse_type; +static PyTypeObject count_type; + +#include "clinic/itertoolsmodule.c.h" + + /* groupby object ************************************************************/ typedef struct { @@ -63,23 +63,23 @@ typedef struct { static PyObject *_grouper_create(groupbyobject *, PyObject *); -/*[clinic input] -@classmethod -itertools.groupby.__new__ - - iterable as it: object - Elements to divide into groups according to the key function. - key as keyfunc: object = None - A function for computing the group category for each element. - If the key function is not specified or is None, the element itself - is used for grouping. - -make an iterator that returns consecutive keys and groups from the iterable -[clinic start generated code]*/ - +/*[clinic input] +@classmethod +itertools.groupby.__new__ + + iterable as it: object + Elements to divide into groups according to the key function. + key as keyfunc: object = None + A function for computing the group category for each element. + If the key function is not specified or is None, the element itself + is used for grouping. + +make an iterator that returns consecutive keys and groups from the iterable +[clinic start generated code]*/ + static PyObject * -itertools_groupby_impl(PyTypeObject *type, PyObject *it, PyObject *keyfunc) -/*[clinic end generated code: output=cbb1ae3a90fd4141 input=6b3d123e87ff65a1]*/ +itertools_groupby_impl(PyTypeObject *type, PyObject *it, PyObject *keyfunc) +/*[clinic end generated code: output=cbb1ae3a90fd4141 input=6b3d123e87ff65a1]*/ { groupbyobject *gbo; @@ -135,7 +135,7 @@ groupby_step(groupbyobject *gbo) newkey = newvalue; Py_INCREF(newvalue); } else { - newkey = PyObject_CallOneArg(gbo->keyfunc, newvalue); + newkey = PyObject_CallOneArg(gbo->keyfunc, newvalue); if (newkey == NULL) { Py_DECREF(newvalue); return -1; @@ -187,7 +187,7 @@ groupby_next(groupbyobject *gbo) } static PyObject * -groupby_reduce(groupbyobject *lz, PyObject *Py_UNUSED(ignored)) +groupby_reduce(groupbyobject *lz, PyObject *Py_UNUSED(ignored)) { /* reduce as a 'new' call with an optional 'setstate' if groupby * has started @@ -242,10 +242,10 @@ static PyTypeObject groupby_type = { 0, /* tp_itemsize */ /* methods */ (destructor)groupby_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -258,7 +258,7 @@ static PyTypeObject groupby_type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ - itertools_groupby__doc__, /* tp_doc */ + itertools_groupby__doc__, /* tp_doc */ (traverseproc)groupby_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ @@ -275,7 +275,7 @@ static PyTypeObject groupby_type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - itertools_groupby, /* tp_new */ + itertools_groupby, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; @@ -288,19 +288,19 @@ typedef struct { PyObject *tgtkey; } _grouperobject; -/*[clinic input] -@classmethod -itertools._grouper.__new__ +/*[clinic input] +@classmethod +itertools._grouper.__new__ + + parent: object(subclass_of='&groupby_type') + tgtkey: object + / +[clinic start generated code]*/ - parent: object(subclass_of='&groupby_type') - tgtkey: object - / -[clinic start generated code]*/ - static PyObject * -itertools__grouper_impl(PyTypeObject *type, PyObject *parent, - PyObject *tgtkey) -/*[clinic end generated code: output=462efb1cdebb5914 input=dc180d7771fc8c59]*/ +itertools__grouper_impl(PyTypeObject *type, PyObject *parent, + PyObject *tgtkey) +/*[clinic end generated code: output=462efb1cdebb5914 input=dc180d7771fc8c59]*/ { return _grouper_create((groupbyobject*) parent, tgtkey); } @@ -368,11 +368,11 @@ _grouper_next(_grouperobject *igo) } static PyObject * -_grouper_reduce(_grouperobject *lz, PyObject *Py_UNUSED(ignored)) +_grouper_reduce(_grouperobject *lz, PyObject *Py_UNUSED(ignored)) { - _Py_IDENTIFIER(iter); + _Py_IDENTIFIER(iter); if (((groupbyobject *)lz->parent)->currgrouper != lz) { - return Py_BuildValue("N(())", _PyEval_GetBuiltinId(&PyId_iter)); + return Py_BuildValue("N(())", _PyEval_GetBuiltinId(&PyId_iter)); } return Py_BuildValue("O(OO)", Py_TYPE(lz), lz->parent, lz->tgtkey); } @@ -391,10 +391,10 @@ static PyTypeObject _grouper_type = { 0, /* tp_itemsize */ /* methods */ (destructor)_grouper_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -423,7 +423,7 @@ static PyTypeObject _grouper_type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - itertools__grouper, /* tp_new */ + itertools__grouper, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; @@ -444,7 +444,7 @@ typedef struct { PyObject_HEAD PyObject *it; int numread; /* 0 <= numread <= LINKCELLS */ - int running; + int running; PyObject *nextlink; PyObject *(values[LINKCELLS]); } teedataobject; @@ -465,7 +465,7 @@ teedataobject_newinternal(PyObject *it) if (tdo == NULL) return NULL; - tdo->running = 0; + tdo->running = 0; tdo->numread = 0; tdo->nextlink = NULL; Py_INCREF(it); @@ -494,14 +494,14 @@ teedataobject_getitem(teedataobject *tdo, int i) else { /* this is the lead iterator, so fetch more data */ assert(i == tdo->numread); - if (tdo->running) { - PyErr_SetString(PyExc_RuntimeError, - "cannot re-enter the tee iterator"); - return NULL; - } - tdo->running = 1; + if (tdo->running) { + PyErr_SetString(PyExc_RuntimeError, + "cannot re-enter the tee iterator"); + return NULL; + } + tdo->running = 1; value = PyIter_Next(tdo->it); - tdo->running = 0; + tdo->running = 0; if (value == NULL) return NULL; tdo->numread++; @@ -526,7 +526,7 @@ teedataobject_traverse(teedataobject *tdo, visitproc visit, void * arg) static void teedataobject_safe_decref(PyObject *obj) { - while (obj && Py_IS_TYPE(obj, &teedataobject_type) && + while (obj && Py_IS_TYPE(obj, &teedataobject_type) && Py_REFCNT(obj) == 1) { PyObject *nextlink = ((teedataobject *)obj)->nextlink; ((teedataobject *)obj)->nextlink = NULL; @@ -560,7 +560,7 @@ teedataobject_dealloc(teedataobject *tdo) } static PyObject * -teedataobject_reduce(teedataobject *tdo, PyObject *Py_UNUSED(ignored)) +teedataobject_reduce(teedataobject *tdo, PyObject *Py_UNUSED(ignored)) { int i; /* create a temporary list of already iterated values */ @@ -577,20 +577,20 @@ teedataobject_reduce(teedataobject *tdo, PyObject *Py_UNUSED(ignored)) tdo->nextlink ? tdo->nextlink : Py_None); } -/*[clinic input] -@classmethod -itertools.teedataobject.__new__ - iterable as it: object - values: object(subclass_of='&PyList_Type') - next: object - / -Data container common to multiple tee objects. -[clinic start generated code]*/ +/*[clinic input] +@classmethod +itertools.teedataobject.__new__ + iterable as it: object + values: object(subclass_of='&PyList_Type') + next: object + / +Data container common to multiple tee objects. +[clinic start generated code]*/ static PyObject * -itertools_teedataobject_impl(PyTypeObject *type, PyObject *it, - PyObject *values, PyObject *next) -/*[clinic end generated code: output=3343ceb07e08df5e input=be60f2fabd2b72ba]*/ +itertools_teedataobject_impl(PyTypeObject *type, PyObject *it, + PyObject *values, PyObject *next) +/*[clinic end generated code: output=3343ceb07e08df5e input=be60f2fabd2b72ba]*/ { teedataobject *tdo; Py_ssize_t i, len; @@ -613,7 +613,7 @@ itertools_teedataobject_impl(PyTypeObject *type, PyObject *it, if (len == LINKCELLS) { if (next != Py_None) { - if (!Py_IS_TYPE(next, &teedataobject_type)) + if (!Py_IS_TYPE(next, &teedataobject_type)) goto err; assert(tdo->nextlink == NULL); Py_INCREF(next); @@ -644,10 +644,10 @@ static PyTypeObject teedataobject_type = { 0, /* tp_itemsize */ /* methods */ (destructor)teedataobject_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -659,7 +659,7 @@ static PyTypeObject teedataobject_type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - itertools_teedataobject__doc__, /* tp_doc */ + itertools_teedataobject__doc__, /* tp_doc */ (traverseproc)teedataobject_traverse, /* tp_traverse */ (inquiry)teedataobject_clear, /* tp_clear */ 0, /* tp_richcompare */ @@ -676,7 +676,7 @@ static PyTypeObject teedataobject_type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - itertools_teedataobject, /* tp_new */ + itertools_teedataobject, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; @@ -708,7 +708,7 @@ tee_traverse(teeobject *to, visitproc visit, void *arg) } static PyObject * -tee_copy(teeobject *to, PyObject *Py_UNUSED(ignored)) +tee_copy(teeobject *to, PyObject *Py_UNUSED(ignored)) { teeobject *newto; @@ -729,46 +729,46 @@ static PyObject * tee_fromiterable(PyObject *iterable) { teeobject *to; - PyObject *it; + PyObject *it; it = PyObject_GetIter(iterable); if (it == NULL) return NULL; if (PyObject_TypeCheck(it, &tee_type)) { - to = (teeobject *)tee_copy((teeobject *)it, NULL); + to = (teeobject *)tee_copy((teeobject *)it, NULL); goto done; } - PyObject *dataobj = teedataobject_newinternal(it); - if (!dataobj) { + PyObject *dataobj = teedataobject_newinternal(it); + if (!dataobj) { to = NULL; goto done; } - to = PyObject_GC_New(teeobject, &tee_type); - if (to == NULL) { - Py_DECREF(dataobj); - goto done; - } - to->dataobj = (teedataobject *)dataobj; + to = PyObject_GC_New(teeobject, &tee_type); + if (to == NULL) { + Py_DECREF(dataobj); + goto done; + } + to->dataobj = (teedataobject *)dataobj; to->index = 0; to->weakreflist = NULL; PyObject_GC_Track(to); done: - Py_DECREF(it); + Py_DECREF(it); return (PyObject *)to; } -/*[clinic input] -@classmethod -itertools._tee.__new__ - iterable: object - / -Iterator wrapped to make it copyable. -[clinic start generated code]*/ - +/*[clinic input] +@classmethod +itertools._tee.__new__ + iterable: object + / +Iterator wrapped to make it copyable. +[clinic start generated code]*/ + static PyObject * -itertools__tee_impl(PyTypeObject *type, PyObject *iterable) -/*[clinic end generated code: output=b02d3fd26c810c3f input=adc0779d2afe37a2]*/ +itertools__tee_impl(PyTypeObject *type, PyObject *iterable) +/*[clinic end generated code: output=b02d3fd26c810c3f input=adc0779d2afe37a2]*/ { return tee_fromiterable(iterable); } @@ -791,7 +791,7 @@ tee_dealloc(teeobject *to) } static PyObject * -tee_reduce(teeobject *to, PyObject *Py_UNUSED(ignored)) +tee_reduce(teeobject *to, PyObject *Py_UNUSED(ignored)) { return Py_BuildValue("O(())(Oi)", Py_TYPE(to), to->dataobj, to->index); } @@ -832,10 +832,10 @@ static PyTypeObject tee_type = { 0, /* tp_itemsize */ /* methods */ (destructor)tee_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -847,7 +847,7 @@ static PyTypeObject tee_type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - itertools__tee__doc__, /* tp_doc */ + itertools__tee__doc__, /* tp_doc */ (traverseproc)tee_traverse, /* tp_traverse */ (inquiry)tee_clear, /* tp_clear */ 0, /* tp_richcompare */ @@ -864,24 +864,24 @@ static PyTypeObject tee_type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - itertools__tee, /* tp_new */ + itertools__tee, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; -/*[clinic input] -itertools.tee - iterable: object - n: Py_ssize_t = 2 - / -Returns a tuple of n independent iterators. -[clinic start generated code]*/ - +/*[clinic input] +itertools.tee + iterable: object + n: Py_ssize_t = 2 + / +Returns a tuple of n independent iterators. +[clinic start generated code]*/ + static PyObject * -itertools_tee_impl(PyObject *module, PyObject *iterable, Py_ssize_t n) -/*[clinic end generated code: output=1c64519cd859c2f0 input=c99a1472c425d66d]*/ +itertools_tee_impl(PyObject *module, PyObject *iterable, Py_ssize_t n) +/*[clinic end generated code: output=1c64519cd859c2f0 input=c99a1472c425d66d]*/ { - Py_ssize_t i; - PyObject *it, *copyable, *copyfunc, *result; + Py_ssize_t i; + PyObject *it, *copyable, *copyfunc, *result; _Py_IDENTIFIER(__copy__); if (n < 0) { @@ -947,17 +947,17 @@ typedef struct { int firstpass; } cycleobject; -/*[clinic input] -@classmethod -itertools.cycle.__new__ - iterable: object - / -Return elements from the iterable until it is exhausted. Then repeat the sequence indefinitely. -[clinic start generated code]*/ - +/*[clinic input] +@classmethod +itertools.cycle.__new__ + iterable: object + / +Return elements from the iterable until it is exhausted. Then repeat the sequence indefinitely. +[clinic start generated code]*/ + static PyObject * -itertools_cycle_impl(PyTypeObject *type, PyObject *iterable) -/*[clinic end generated code: output=f60e5ec17a45b35c input=9d1d84bcf66e908b]*/ +itertools_cycle_impl(PyTypeObject *type, PyObject *iterable) +/*[clinic end generated code: output=f60e5ec17a45b35c input=9d1d84bcf66e908b]*/ { PyObject *it; PyObject *saved; @@ -1039,7 +1039,7 @@ cycle_next(cycleobject *lz) } static PyObject * -cycle_reduce(cycleobject *lz, PyObject *Py_UNUSED(ignored)) +cycle_reduce(cycleobject *lz, PyObject *Py_UNUSED(ignored)) { /* Create a new cycle with the iterator tuple, then set the saved state */ if (lz->it == NULL) { @@ -1056,10 +1056,10 @@ cycle_reduce(cycleobject *lz, PyObject *Py_UNUSED(ignored)) } Py_DECREF(res); } - return Py_BuildValue("O(N)(OO)", Py_TYPE(lz), it, lz->saved, Py_True); + return Py_BuildValue("O(N)(OO)", Py_TYPE(lz), it, lz->saved, Py_True); } - return Py_BuildValue("O(O)(OO)", Py_TYPE(lz), lz->it, lz->saved, - lz->firstpass ? Py_True : Py_False); + return Py_BuildValue("O(O)(OO)", Py_TYPE(lz), lz->it, lz->saved, + lz->firstpass ? Py_True : Py_False); } static PyObject * @@ -1096,10 +1096,10 @@ static PyTypeObject cycle_type = { 0, /* tp_itemsize */ /* methods */ (destructor)cycle_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1112,7 +1112,7 @@ static PyTypeObject cycle_type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ - itertools_cycle__doc__, /* tp_doc */ + itertools_cycle__doc__, /* tp_doc */ (traverseproc)cycle_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ @@ -1129,7 +1129,7 @@ static PyTypeObject cycle_type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - itertools_cycle, /* tp_new */ + itertools_cycle, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; @@ -1143,20 +1143,20 @@ typedef struct { long start; } dropwhileobject; -/*[clinic input] -@classmethod -itertools.dropwhile.__new__ - predicate as func: object - iterable as seq: object - / -Drop items from the iterable while predicate(item) is true. - -Afterwards, return every element until the iterable is exhausted. -[clinic start generated code]*/ - +/*[clinic input] +@classmethod +itertools.dropwhile.__new__ + predicate as func: object + iterable as seq: object + / +Drop items from the iterable while predicate(item) is true. + +Afterwards, return every element until the iterable is exhausted. +[clinic start generated code]*/ + static PyObject * -itertools_dropwhile_impl(PyTypeObject *type, PyObject *func, PyObject *seq) -/*[clinic end generated code: output=92f9d0d89af149e4 input=d39737147c9f0a26]*/ +itertools_dropwhile_impl(PyTypeObject *type, PyObject *func, PyObject *seq) +/*[clinic end generated code: output=92f9d0d89af149e4 input=d39737147c9f0a26]*/ { PyObject *it; dropwhileobject *lz; @@ -1213,7 +1213,7 @@ dropwhile_next(dropwhileobject *lz) if (lz->start == 1) return item; - good = PyObject_CallOneArg(lz->func, item); + good = PyObject_CallOneArg(lz->func, item); if (good == NULL) { Py_DECREF(item); return NULL; @@ -1231,7 +1231,7 @@ dropwhile_next(dropwhileobject *lz) } static PyObject * -dropwhile_reduce(dropwhileobject *lz, PyObject *Py_UNUSED(ignored)) +dropwhile_reduce(dropwhileobject *lz, PyObject *Py_UNUSED(ignored)) { return Py_BuildValue("O(OO)l", Py_TYPE(lz), lz->func, lz->it, lz->start); } @@ -1261,10 +1261,10 @@ static PyTypeObject dropwhile_type = { 0, /* tp_itemsize */ /* methods */ (destructor)dropwhile_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1277,7 +1277,7 @@ static PyTypeObject dropwhile_type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ - itertools_dropwhile__doc__, /* tp_doc */ + itertools_dropwhile__doc__, /* tp_doc */ (traverseproc)dropwhile_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ @@ -1294,7 +1294,7 @@ static PyTypeObject dropwhile_type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - itertools_dropwhile, /* tp_new */ + itertools_dropwhile, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; @@ -1308,18 +1308,18 @@ typedef struct { long stop; } takewhileobject; -/*[clinic input] -@classmethod -itertools.takewhile.__new__ - predicate as func: object - iterable as seq: object - / -Return successive entries from an iterable as long as the predicate evaluates to true for each entry. -[clinic start generated code]*/ - +/*[clinic input] +@classmethod +itertools.takewhile.__new__ + predicate as func: object + iterable as seq: object + / +Return successive entries from an iterable as long as the predicate evaluates to true for each entry. +[clinic start generated code]*/ + static PyObject * -itertools_takewhile_impl(PyTypeObject *type, PyObject *func, PyObject *seq) -/*[clinic end generated code: output=bb179ea7864e2ef6 input=ba5255f7519aa119]*/ +itertools_takewhile_impl(PyTypeObject *type, PyObject *func, PyObject *seq) +/*[clinic end generated code: output=bb179ea7864e2ef6 input=ba5255f7519aa119]*/ { PyObject *it; takewhileobject *lz; @@ -1374,7 +1374,7 @@ takewhile_next(takewhileobject *lz) if (item == NULL) return NULL; - good = PyObject_CallOneArg(lz->func, item); + good = PyObject_CallOneArg(lz->func, item); if (good == NULL) { Py_DECREF(item); return NULL; @@ -1390,7 +1390,7 @@ takewhile_next(takewhileobject *lz) } static PyObject * -takewhile_reduce(takewhileobject *lz, PyObject *Py_UNUSED(ignored)) +takewhile_reduce(takewhileobject *lz, PyObject *Py_UNUSED(ignored)) { return Py_BuildValue("O(OO)l", Py_TYPE(lz), lz->func, lz->it, lz->stop); } @@ -1421,10 +1421,10 @@ static PyTypeObject takewhile_type = { 0, /* tp_itemsize */ /* methods */ (destructor)takewhile_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1437,7 +1437,7 @@ static PyTypeObject takewhile_type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ - itertools_takewhile__doc__, /* tp_doc */ + itertools_takewhile__doc__, /* tp_doc */ (traverseproc)takewhile_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ @@ -1454,7 +1454,7 @@ static PyTypeObject takewhile_type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - itertools_takewhile, /* tp_new */ + itertools_takewhile, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; @@ -1611,7 +1611,7 @@ empty: } static PyObject * -islice_reduce(isliceobject *lz, PyObject *Py_UNUSED(ignored)) +islice_reduce(isliceobject *lz, PyObject *Py_UNUSED(ignored)) { /* When unpickled, generate a new object with the same bounds, * then 'setstate' with the next and count @@ -1669,7 +1669,7 @@ islice(iterable, start, stop[, step]) --> islice object\n\ Return an iterator whose next() method returns selected values from an\n\ iterable. If start is specified, will skip all preceding elements;\n\ otherwise, start defaults to zero. Step defaults to one. If\n\ -specified as another value, step determines how many values are\n\ +specified as another value, step determines how many values are\n\ skipped between successive calls. Works like a slice() on a list\n\ but returns an iterator."); @@ -1680,10 +1680,10 @@ static PyTypeObject islice_type = { 0, /* tp_itemsize */ /* methods */ (destructor)islice_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1726,18 +1726,18 @@ typedef struct { PyObject *it; } starmapobject; -/*[clinic input] -@classmethod -itertools.starmap.__new__ - function as func: object - iterable as seq: object - / -Return an iterator whose values are returned from the function evaluated with an argument tuple taken from the given sequence. -[clinic start generated code]*/ - +/*[clinic input] +@classmethod +itertools.starmap.__new__ + function as func: object + iterable as seq: object + / +Return an iterator whose values are returned from the function evaluated with an argument tuple taken from the given sequence. +[clinic start generated code]*/ + static PyObject * -itertools_starmap_impl(PyTypeObject *type, PyObject *func, PyObject *seq) -/*[clinic end generated code: output=79eeb81d452c6e8d input=844766df6a0d4dad]*/ +itertools_starmap_impl(PyTypeObject *type, PyObject *func, PyObject *seq) +/*[clinic end generated code: output=79eeb81d452c6e8d input=844766df6a0d4dad]*/ { PyObject *it; starmapobject *lz; @@ -1800,7 +1800,7 @@ starmap_next(starmapobject *lz) } static PyObject * -starmap_reduce(starmapobject *lz, PyObject *Py_UNUSED(ignored)) +starmap_reduce(starmapobject *lz, PyObject *Py_UNUSED(ignored)) { /* Just pickle the iterator */ return Py_BuildValue("O(OO)", Py_TYPE(lz), lz->func, lz->it); @@ -1819,10 +1819,10 @@ static PyTypeObject starmap_type = { 0, /* tp_itemsize */ /* methods */ (destructor)starmap_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1835,7 +1835,7 @@ static PyTypeObject starmap_type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ - itertools_starmap__doc__, /* tp_doc */ + itertools_starmap__doc__, /* tp_doc */ (traverseproc)starmap_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ @@ -1852,7 +1852,7 @@ static PyTypeObject starmap_type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - itertools_starmap, /* tp_new */ + itertools_starmap, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; @@ -1898,17 +1898,17 @@ chain_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return chain_new_internal(type, source); } -/*[clinic input] -@classmethod -itertools.chain.from_iterable - iterable as arg: object - / -Alternative chain() constructor taking a single iterable argument that evaluates lazily. -[clinic start generated code]*/ - +/*[clinic input] +@classmethod +itertools.chain.from_iterable + iterable as arg: object + / +Alternative chain() constructor taking a single iterable argument that evaluates lazily. +[clinic start generated code]*/ + static PyObject * -itertools_chain_from_iterable(PyTypeObject *type, PyObject *arg) -/*[clinic end generated code: output=667ae7a7f7b68654 input=72c39e3a2ca3be85]*/ +itertools_chain_from_iterable(PyTypeObject *type, PyObject *arg) +/*[clinic end generated code: output=667ae7a7f7b68654 input=72c39e3a2ca3be85]*/ { PyObject *source; @@ -1975,7 +1975,7 @@ chain_next(chainobject *lz) } static PyObject * -chain_reduce(chainobject *lz, PyObject *Py_UNUSED(ignored)) +chain_reduce(chainobject *lz, PyObject *Py_UNUSED(ignored)) { if (lz->source) { /* we can't pickle function objects (itertools.from_iterable) so @@ -2025,13 +2025,13 @@ first iterable until it is exhausted, then elements from the next\n\ iterable, until all of the iterables are exhausted."); static PyMethodDef chain_methods[] = { - ITERTOOLS_CHAIN_FROM_ITERABLE_METHODDEF + ITERTOOLS_CHAIN_FROM_ITERABLE_METHODDEF {"__reduce__", (PyCFunction)chain_reduce, METH_NOARGS, reduce_doc}, {"__setstate__", (PyCFunction)chain_setstate, METH_O, setstate_doc}, - {"__class_getitem__", (PyCFunction)Py_GenericAlias, - METH_O|METH_CLASS, PyDoc_STR("See PEP 585")}, + {"__class_getitem__", (PyCFunction)Py_GenericAlias, + METH_O|METH_CLASS, PyDoc_STR("See PEP 585")}, {NULL, NULL} /* sentinel */ }; @@ -2042,10 +2042,10 @@ static PyTypeObject chain_type = { 0, /* tp_itemsize */ /* methods */ (destructor)chain_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2241,17 +2241,17 @@ product_next(productobject *lz) /* Copy the previous result tuple or re-use it if available */ if (Py_REFCNT(result) > 1) { PyObject *old_result = result; - result = _PyTuple_FromArray(_PyTuple_ITEMS(old_result), npools); + result = _PyTuple_FromArray(_PyTuple_ITEMS(old_result), npools); if (result == NULL) goto empty; lz->result = result; Py_DECREF(old_result); } - // bpo-42536: The GC may have untracked this result tuple. Since we're - // recycling it, make sure it's tracked again: - else if (!_PyObject_GC_IS_TRACKED(result)) { - _PyObject_GC_TRACK(result); - } + // bpo-42536: The GC may have untracked this result tuple. Since we're + // recycling it, make sure it's tracked again: + else if (!_PyObject_GC_IS_TRACKED(result)) { + _PyObject_GC_TRACK(result); + } /* Now, we've got the only copy so we can update it in-place */ assert (npools==0 || Py_REFCNT(result) == 1); @@ -2294,7 +2294,7 @@ empty: } static PyObject * -product_reduce(productobject *lz, PyObject *Py_UNUSED(ignored)) +product_reduce(productobject *lz, PyObject *Py_UNUSED(ignored)) { if (lz->stopped) { return Py_BuildValue("O(())", Py_TYPE(lz)); @@ -2400,10 +2400,10 @@ static PyTypeObject product_type = { 0, /* tp_itemsize */ /* methods */ (destructor)product_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2450,20 +2450,20 @@ typedef struct { } combinationsobject; -/*[clinic input] -@classmethod -itertools.combinations.__new__ - iterable: object - r: Py_ssize_t -Return successive r-length combinations of elements in the iterable. - -combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3) -[clinic start generated code]*/ - +/*[clinic input] +@classmethod +itertools.combinations.__new__ + iterable: object + r: Py_ssize_t +Return successive r-length combinations of elements in the iterable. + +combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3) +[clinic start generated code]*/ + static PyObject * -itertools_combinations_impl(PyTypeObject *type, PyObject *iterable, - Py_ssize_t r) -/*[clinic end generated code: output=87a689b39c40039c input=06bede09e3da20f8]*/ +itertools_combinations_impl(PyTypeObject *type, PyObject *iterable, + Py_ssize_t r) +/*[clinic end generated code: output=87a689b39c40039c input=06bede09e3da20f8]*/ { combinationsobject *co; Py_ssize_t n; @@ -2569,17 +2569,17 @@ combinations_next(combinationsobject *co) /* Copy the previous result tuple or re-use it if available */ if (Py_REFCNT(result) > 1) { PyObject *old_result = result; - result = _PyTuple_FromArray(_PyTuple_ITEMS(old_result), r); + result = _PyTuple_FromArray(_PyTuple_ITEMS(old_result), r); if (result == NULL) goto empty; co->result = result; Py_DECREF(old_result); } - // bpo-42536: The GC may have untracked this result tuple. Since we're - // recycling it, make sure it's tracked again: - else if (!_PyObject_GC_IS_TRACKED(result)) { - _PyObject_GC_TRACK(result); - } + // bpo-42536: The GC may have untracked this result tuple. Since we're + // recycling it, make sure it's tracked again: + else if (!_PyObject_GC_IS_TRACKED(result)) { + _PyObject_GC_TRACK(result); + } /* Now, we've got the only copy so we can update it in-place * CPython's empty tuple is a singleton and cached in * PyTuple's freelist. @@ -2625,7 +2625,7 @@ empty: } static PyObject * -combinations_reduce(combinationsobject *lz, PyObject *Py_UNUSED(ignored)) +combinations_reduce(combinationsobject *lz, PyObject *Py_UNUSED(ignored)) { if (lz->result == NULL) { return Py_BuildValue("O(On)", Py_TYPE(lz), lz->pool, lz->r); @@ -2711,10 +2711,10 @@ static PyTypeObject combinations_type = { 0, /* tp_itemsize */ /* methods */ (destructor)combinations_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2727,7 +2727,7 @@ static PyTypeObject combinations_type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ - itertools_combinations__doc__, /* tp_doc */ + itertools_combinations__doc__, /* tp_doc */ (traverseproc)combinations_traverse,/* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ @@ -2744,7 +2744,7 @@ static PyTypeObject combinations_type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - itertools_combinations, /* tp_new */ + itertools_combinations, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; @@ -2786,21 +2786,21 @@ typedef struct { int stopped; /* set to 1 when the cwr iterator is exhausted */ } cwrobject; -/*[clinic input] -@classmethod -itertools.combinations_with_replacement.__new__ - iterable: object - r: Py_ssize_t -Return successive r-length combinations of elements in the iterable allowing individual elements to have successive repeats. - -combinations_with_replacement('ABC', 2) --> AA AB AC BB BC CC" -[clinic start generated code]*/ - +/*[clinic input] +@classmethod +itertools.combinations_with_replacement.__new__ + iterable: object + r: Py_ssize_t +Return successive r-length combinations of elements in the iterable allowing individual elements to have successive repeats. + +combinations_with_replacement('ABC', 2) --> AA AB AC BB BC CC" +[clinic start generated code]*/ + static PyObject * -itertools_combinations_with_replacement_impl(PyTypeObject *type, - PyObject *iterable, - Py_ssize_t r) -/*[clinic end generated code: output=48b26856d4e659ca input=dc2a8c7ba785fad7]*/ +itertools_combinations_with_replacement_impl(PyTypeObject *type, + PyObject *iterable, + Py_ssize_t r) +/*[clinic end generated code: output=48b26856d4e659ca input=dc2a8c7ba785fad7]*/ { cwrobject *co; Py_ssize_t n; @@ -2908,17 +2908,17 @@ cwr_next(cwrobject *co) /* Copy the previous result tuple or re-use it if available */ if (Py_REFCNT(result) > 1) { PyObject *old_result = result; - result = _PyTuple_FromArray(_PyTuple_ITEMS(old_result), r); + result = _PyTuple_FromArray(_PyTuple_ITEMS(old_result), r); if (result == NULL) goto empty; co->result = result; Py_DECREF(old_result); } - // bpo-42536: The GC may have untracked this result tuple. Since we're - // recycling it, make sure it's tracked again: - else if (!_PyObject_GC_IS_TRACKED(result)) { - _PyObject_GC_TRACK(result); - } + // bpo-42536: The GC may have untracked this result tuple. Since we're + // recycling it, make sure it's tracked again: + else if (!_PyObject_GC_IS_TRACKED(result)) { + _PyObject_GC_TRACK(result); + } /* Now, we've got the only copy so we can update it in-place CPython's empty tuple is a singleton and cached in PyTuple's freelist. */ assert(r == 0 || Py_REFCNT(result) == 1); @@ -2956,7 +2956,7 @@ empty: } static PyObject * -cwr_reduce(cwrobject *lz, PyObject *Py_UNUSED(ignored)) +cwr_reduce(cwrobject *lz, PyObject *Py_UNUSED(ignored)) { if (lz->result == NULL) { return Py_BuildValue("O(On)", Py_TYPE(lz), lz->pool, lz->r); @@ -3038,10 +3038,10 @@ static PyTypeObject cwr_type = { 0, /* tp_itemsize */ /* methods */ (destructor)cwr_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -3054,7 +3054,7 @@ static PyTypeObject cwr_type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ - itertools_combinations_with_replacement__doc__, /* tp_doc */ + itertools_combinations_with_replacement__doc__, /* tp_doc */ (traverseproc)cwr_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ @@ -3071,7 +3071,7 @@ static PyTypeObject cwr_type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - itertools_combinations_with_replacement, /* tp_new */ + itertools_combinations_with_replacement, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; @@ -3079,15 +3079,15 @@ static PyTypeObject cwr_type = { /* permutations object ******************************************************** def permutations(iterable, r=None): - # permutations('ABCD', 2) --> AB AC AD BA BC BD CA CB CD DA DB DC - # permutations(range(3)) --> 012 021 102 120 201 210 + # permutations('ABCD', 2) --> AB AC AD BA BC BD CA CB CD DA DB DC + # permutations(range(3)) --> 012 021 102 120 201 210 pool = tuple(iterable) n = len(pool) r = n if r is None else r - if r > n: - return - indices = list(range(n)) - cycles = list(range(n, n-r, -1)) + if r > n: + return + indices = list(range(n)) + cycles = list(range(n, n-r, -1)) yield tuple(pool[i] for i in indices[:r]) while n: for i in reversed(range(r)): @@ -3114,20 +3114,20 @@ typedef struct { int stopped; /* set to 1 when the iterator is exhausted */ } permutationsobject; -/*[clinic input] -@classmethod -itertools.permutations.__new__ - iterable: object - r as robj: object = None -Return successive r-length permutations of elements in the iterable. - -permutations(range(3), 2) --> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1) -[clinic start generated code]*/ - +/*[clinic input] +@classmethod +itertools.permutations.__new__ + iterable: object + r as robj: object = None +Return successive r-length permutations of elements in the iterable. + +permutations(range(3), 2) --> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1) +[clinic start generated code]*/ + static PyObject * -itertools_permutations_impl(PyTypeObject *type, PyObject *iterable, - PyObject *robj) -/*[clinic end generated code: output=296a72fa76d620ea input=57d0170a4ac0ec7a]*/ +itertools_permutations_impl(PyTypeObject *type, PyObject *iterable, + PyObject *robj) +/*[clinic end generated code: output=296a72fa76d620ea input=57d0170a4ac0ec7a]*/ { permutationsobject *po; Py_ssize_t n; @@ -3257,17 +3257,17 @@ permutations_next(permutationsobject *po) /* Copy the previous result tuple or re-use it if available */ if (Py_REFCNT(result) > 1) { PyObject *old_result = result; - result = _PyTuple_FromArray(_PyTuple_ITEMS(old_result), r); + result = _PyTuple_FromArray(_PyTuple_ITEMS(old_result), r); if (result == NULL) goto empty; po->result = result; Py_DECREF(old_result); } - // bpo-42536: The GC may have untracked this result tuple. Since we're - // recycling it, make sure it's tracked again: - else if (!_PyObject_GC_IS_TRACKED(result)) { - _PyObject_GC_TRACK(result); - } + // bpo-42536: The GC may have untracked this result tuple. Since we're + // recycling it, make sure it's tracked again: + else if (!_PyObject_GC_IS_TRACKED(result)) { + _PyObject_GC_TRACK(result); + } /* Now, we've got the only copy so we can update it in-place */ assert(r == 0 || Py_REFCNT(result) == 1); @@ -3314,7 +3314,7 @@ empty: } static PyObject * -permutations_reduce(permutationsobject *po, PyObject *Py_UNUSED(ignored)) +permutations_reduce(permutationsobject *po, PyObject *Py_UNUSED(ignored)) { if (po->result == NULL) { return Py_BuildValue("O(On)", Py_TYPE(po), po->pool, po->r); @@ -3430,10 +3430,10 @@ static PyTypeObject permutations_type = { 0, /* tp_itemsize */ /* methods */ (destructor)permutations_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -3446,7 +3446,7 @@ static PyTypeObject permutations_type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ - itertools_permutations__doc__, /* tp_doc */ + itertools_permutations__doc__, /* tp_doc */ (traverseproc)permutations_traverse,/* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ @@ -3463,11 +3463,11 @@ static PyTypeObject permutations_type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - itertools_permutations, /* tp_new */ + itertools_permutations, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; - + /* accumulate object ********************************************************/ typedef struct { @@ -3475,23 +3475,23 @@ typedef struct { PyObject *total; PyObject *it; PyObject *binop; - PyObject *initial; + PyObject *initial; } accumulateobject; -/*[clinic input] -@classmethod -itertools.accumulate.__new__ - iterable: object - func as binop: object = None - * - initial: object = None -Return series of accumulated sums (or other binary function results). -[clinic start generated code]*/ - +/*[clinic input] +@classmethod +itertools.accumulate.__new__ + iterable: object + func as binop: object = None + * + initial: object = None +Return series of accumulated sums (or other binary function results). +[clinic start generated code]*/ + static PyObject * -itertools_accumulate_impl(PyTypeObject *type, PyObject *iterable, - PyObject *binop, PyObject *initial) -/*[clinic end generated code: output=66da2650627128f8 input=c4ce20ac59bf7ffd]*/ +itertools_accumulate_impl(PyTypeObject *type, PyObject *iterable, + PyObject *binop, PyObject *initial) +/*[clinic end generated code: output=66da2650627128f8 input=c4ce20ac59bf7ffd]*/ { PyObject *it; accumulateobject *lz; @@ -3514,8 +3514,8 @@ itertools_accumulate_impl(PyTypeObject *type, PyObject *iterable, } lz->total = NULL; lz->it = it; - Py_XINCREF(initial); - lz->initial = initial; + Py_XINCREF(initial); + lz->initial = initial; return (PyObject *)lz; } @@ -3526,7 +3526,7 @@ accumulate_dealloc(accumulateobject *lz) Py_XDECREF(lz->binop); Py_XDECREF(lz->total); Py_XDECREF(lz->it); - Py_XDECREF(lz->initial); + Py_XDECREF(lz->initial); Py_TYPE(lz)->tp_free(lz); } @@ -3536,7 +3536,7 @@ accumulate_traverse(accumulateobject *lz, visitproc visit, void *arg) Py_VISIT(lz->binop); Py_VISIT(lz->it); Py_VISIT(lz->total); - Py_VISIT(lz->initial); + Py_VISIT(lz->initial); return 0; } @@ -3545,13 +3545,13 @@ accumulate_next(accumulateobject *lz) { PyObject *val, *newtotal; - if (lz->initial != Py_None) { - lz->total = lz->initial; - Py_INCREF(Py_None); - lz->initial = Py_None; - Py_INCREF(lz->total); - return lz->total; - } + if (lz->initial != Py_None) { + lz->total = lz->initial; + Py_INCREF(Py_None); + lz->initial = Py_None; + Py_INCREF(lz->total); + return lz->total; + } val = (*Py_TYPE(lz->it)->tp_iternext)(lz->it); if (val == NULL) return NULL; @@ -3576,21 +3576,21 @@ accumulate_next(accumulateobject *lz) } static PyObject * -accumulate_reduce(accumulateobject *lz, PyObject *Py_UNUSED(ignored)) -{ - if (lz->initial != Py_None) { - PyObject *it; - - assert(lz->total == NULL); - if (PyType_Ready(&chain_type) < 0) - return NULL; - it = PyObject_CallFunction((PyObject *)&chain_type, "(O)O", - lz->initial, lz->it); - if (it == NULL) - return NULL; - return Py_BuildValue("O(NO)O", Py_TYPE(lz), - it, lz->binop?lz->binop:Py_None, Py_None); - } +accumulate_reduce(accumulateobject *lz, PyObject *Py_UNUSED(ignored)) +{ + if (lz->initial != Py_None) { + PyObject *it; + + assert(lz->total == NULL); + if (PyType_Ready(&chain_type) < 0) + return NULL; + it = PyObject_CallFunction((PyObject *)&chain_type, "(O)O", + lz->initial, lz->it); + if (it == NULL) + return NULL; + return Py_BuildValue("O(NO)O", Py_TYPE(lz), + it, lz->binop?lz->binop:Py_None, Py_None); + } if (lz->total == Py_None) { PyObject *it; @@ -3636,10 +3636,10 @@ static PyTypeObject accumulate_type = { 0, /* tp_itemsize */ /* methods */ (destructor)accumulate_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -3652,7 +3652,7 @@ static PyTypeObject accumulate_type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ - itertools_accumulate__doc__, /* tp_doc */ + itertools_accumulate__doc__, /* tp_doc */ (traverseproc)accumulate_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ @@ -3669,7 +3669,7 @@ static PyTypeObject accumulate_type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - itertools_accumulate, /* tp_new */ + itertools_accumulate, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; @@ -3689,20 +3689,20 @@ typedef struct { PyObject *selectors; } compressobject; -/*[clinic input] -@classmethod -itertools.compress.__new__ - data as seq1: object - selectors as seq2: object -Return data elements corresponding to true selector elements. - -Forms a shorter iterator from selected data elements using the selectors to -choose the data elements. -[clinic start generated code]*/ - +/*[clinic input] +@classmethod +itertools.compress.__new__ + data as seq1: object + selectors as seq2: object +Return data elements corresponding to true selector elements. + +Forms a shorter iterator from selected data elements using the selectors to +choose the data elements. +[clinic start generated code]*/ + static PyObject * -itertools_compress_impl(PyTypeObject *type, PyObject *seq1, PyObject *seq2) -/*[clinic end generated code: output=7e67157212ed09e0 input=79596d7cd20c77e5]*/ +itertools_compress_impl(PyTypeObject *type, PyObject *seq1, PyObject *seq2) +/*[clinic end generated code: output=7e67157212ed09e0 input=79596d7cd20c77e5]*/ { PyObject *data=NULL, *selectors=NULL; compressobject *lz; @@ -3782,7 +3782,7 @@ compress_next(compressobject *lz) } static PyObject * -compress_reduce(compressobject *lz, PyObject *Py_UNUSED(ignored)) +compress_reduce(compressobject *lz, PyObject *Py_UNUSED(ignored)) { return Py_BuildValue("O(OO)", Py_TYPE(lz), lz->data, lz->selectors); @@ -3801,10 +3801,10 @@ static PyTypeObject compress_type = { 0, /* tp_itemsize */ /* methods */ (destructor)compress_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -3817,7 +3817,7 @@ static PyTypeObject compress_type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ - itertools_compress__doc__, /* tp_doc */ + itertools_compress__doc__, /* tp_doc */ (traverseproc)compress_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ @@ -3834,7 +3834,7 @@ static PyTypeObject compress_type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - itertools_compress, /* tp_new */ + itertools_compress, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; @@ -3847,20 +3847,20 @@ typedef struct { PyObject *it; } filterfalseobject; -/*[clinic input] -@classmethod -itertools.filterfalse.__new__ - function as func: object - iterable as seq: object - / -Return those items of iterable for which function(item) is false. - -If function is None, return the items that are false. -[clinic start generated code]*/ - +/*[clinic input] +@classmethod +itertools.filterfalse.__new__ + function as func: object + iterable as seq: object + / +Return those items of iterable for which function(item) is false. + +If function is None, return the items that are false. +[clinic start generated code]*/ + static PyObject * -itertools_filterfalse_impl(PyTypeObject *type, PyObject *func, PyObject *seq) -/*[clinic end generated code: output=55f87eab9fc0484e input=2d684a2c66f99cde]*/ +itertools_filterfalse_impl(PyTypeObject *type, PyObject *func, PyObject *seq) +/*[clinic end generated code: output=55f87eab9fc0484e input=2d684a2c66f99cde]*/ { PyObject *it; filterfalseobject *lz; @@ -3918,7 +3918,7 @@ filterfalse_next(filterfalseobject *lz) ok = PyObject_IsTrue(item); } else { PyObject *good; - good = PyObject_CallOneArg(lz->func, item); + good = PyObject_CallOneArg(lz->func, item); if (good == NULL) { Py_DECREF(item); return NULL; @@ -3935,7 +3935,7 @@ filterfalse_next(filterfalseobject *lz) } static PyObject * -filterfalse_reduce(filterfalseobject *lz, PyObject *Py_UNUSED(ignored)) +filterfalse_reduce(filterfalseobject *lz, PyObject *Py_UNUSED(ignored)) { return Py_BuildValue("O(OO)", Py_TYPE(lz), lz->func, lz->it); } @@ -3953,10 +3953,10 @@ static PyTypeObject filterfalse_type = { 0, /* tp_itemsize */ /* methods */ (destructor)filterfalse_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -3969,7 +3969,7 @@ static PyTypeObject filterfalse_type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ - itertools_filterfalse__doc__, /* tp_doc */ + itertools_filterfalse__doc__, /* tp_doc */ (traverseproc)filterfalse_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ @@ -3986,7 +3986,7 @@ static PyTypeObject filterfalse_type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - itertools_filterfalse, /* tp_new */ + itertools_filterfalse, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; @@ -4017,25 +4017,25 @@ slow_mode: when cnt == PY_SSIZE_T_MAX, step is not int(1), or cnt is a float. Either long_cnt or long_step may be a float, Fraction, or Decimal. */ -/*[clinic input] -@classmethod -itertools.count.__new__ - start as long_cnt: object(c_default="NULL") = 0 - step as long_step: object(c_default="NULL") = 1 -Return a count object whose .__next__() method returns consecutive values. - -Equivalent to: - def count(firstval=0, step=1): - x = firstval - while 1: - yield x - x += step -[clinic start generated code]*/ - +/*[clinic input] +@classmethod +itertools.count.__new__ + start as long_cnt: object(c_default="NULL") = 0 + step as long_step: object(c_default="NULL") = 1 +Return a count object whose .__next__() method returns consecutive values. + +Equivalent to: + def count(firstval=0, step=1): + x = firstval + while 1: + yield x + x += step +[clinic start generated code]*/ + static PyObject * -itertools_count_impl(PyTypeObject *type, PyObject *long_cnt, - PyObject *long_step) -/*[clinic end generated code: output=09a9250aebd00b1c input=d7a85eec18bfcd94]*/ +itertools_count_impl(PyTypeObject *type, PyObject *long_cnt, + PyObject *long_step) +/*[clinic end generated code: output=09a9250aebd00b1c input=d7a85eec18bfcd94]*/ { countobject *lz; int fast_mode; @@ -4099,7 +4099,7 @@ itertools_count_impl(PyTypeObject *type, PyObject *long_cnt, lz = (countobject *)type->tp_alloc(type, 0); if (lz == NULL) { Py_XDECREF(long_cnt); - Py_DECREF(long_step); + Py_DECREF(long_step); return NULL; } lz->cnt = cnt; @@ -4181,7 +4181,7 @@ count_repr(countobject *lz) } static PyObject * -count_reduce(countobject *lz, PyObject *Py_UNUSED(ignored)) +count_reduce(countobject *lz, PyObject *Py_UNUSED(ignored)) { if (lz->cnt == PY_SSIZE_T_MAX) return Py_BuildValue("O(OO)", Py_TYPE(lz), lz->long_cnt, lz->long_step); @@ -4201,10 +4201,10 @@ static PyTypeObject count_type = { 0, /* tp_itemsize */ /* methods */ (destructor)count_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ (reprfunc)count_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -4217,7 +4217,7 @@ static PyTypeObject count_type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ - itertools_count__doc__, /* tp_doc */ + itertools_count__doc__, /* tp_doc */ (traverseproc)count_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ @@ -4234,7 +4234,7 @@ static PyTypeObject count_type = { 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - itertools_count, /* tp_new */ + itertools_count, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; @@ -4254,17 +4254,17 @@ repeat_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { repeatobject *ro; PyObject *element; - Py_ssize_t cnt = -1, n_args; + Py_ssize_t cnt = -1, n_args; static char *kwargs[] = {"object", "times", NULL}; - n_args = PyTuple_GET_SIZE(args); - if (kwds != NULL) - n_args += PyDict_GET_SIZE(kwds); + n_args = PyTuple_GET_SIZE(args); + if (kwds != NULL) + n_args += PyDict_GET_SIZE(kwds); if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|n:repeat", kwargs, &element, &cnt)) return NULL; /* Does user supply times argument? */ - if (n_args == 2 && cnt < 0) + if (n_args == 2 && cnt < 0) cnt = 0; ro = (repeatobject *)type->tp_alloc(type, 0); @@ -4315,7 +4315,7 @@ repeat_repr(repeatobject *ro) } static PyObject * -repeat_len(repeatobject *ro, PyObject *Py_UNUSED(ignored)) +repeat_len(repeatobject *ro, PyObject *Py_UNUSED(ignored)) { if (ro->cnt == -1) { PyErr_SetString(PyExc_TypeError, "len() of unsized object"); @@ -4327,7 +4327,7 @@ repeat_len(repeatobject *ro, PyObject *Py_UNUSED(ignored)) PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it))."); static PyObject * -repeat_reduce(repeatobject *ro, PyObject *Py_UNUSED(ignored)) +repeat_reduce(repeatobject *ro, PyObject *Py_UNUSED(ignored)) { /* unpickle this so that a new repeat iterator is constructed with an * object, then call __setstate__ on it to set cnt @@ -4356,10 +4356,10 @@ static PyTypeObject repeat_type = { 0, /* tp_itemsize */ /* methods */ (destructor)repeat_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ (reprfunc)repeat_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -4393,7 +4393,7 @@ static PyTypeObject repeat_type = { PyObject_GC_Del, /* tp_free */ }; - + /* ziplongest object *********************************************************/ typedef struct { @@ -4410,7 +4410,7 @@ static PyTypeObject ziplongest_type; static PyObject * zip_longest_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - _Py_IDENTIFIER(fillvalue); + _Py_IDENTIFIER(fillvalue); ziplongestobject *lz; Py_ssize_t i; PyObject *ittuple; /* tuple of iterators */ @@ -4419,15 +4419,15 @@ zip_longest_new(PyTypeObject *type, PyObject *args, PyObject *kwds) Py_ssize_t tuplesize; if (kwds != NULL && PyDict_CheckExact(kwds) && PyDict_GET_SIZE(kwds) > 0) { - fillvalue = NULL; - if (PyDict_GET_SIZE(kwds) == 1) { - fillvalue = _PyDict_GetItemIdWithError(kwds, &PyId_fillvalue); - } - if (fillvalue == NULL) { - if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, - "zip_longest() got an unexpected keyword argument"); - } + fillvalue = NULL; + if (PyDict_GET_SIZE(kwds) == 1) { + fillvalue = _PyDict_GetItemIdWithError(kwds, &PyId_fillvalue); + } + if (fillvalue == NULL) { + if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "zip_longest() got an unexpected keyword argument"); + } return NULL; } } @@ -4537,11 +4537,11 @@ zip_longest_next(ziplongestobject *lz) PyTuple_SET_ITEM(result, i, item); Py_DECREF(olditem); } - // bpo-42536: The GC may have untracked this result tuple. Since we're - // recycling it, make sure it's tracked again: - if (!_PyObject_GC_IS_TRACKED(result)) { - _PyObject_GC_TRACK(result); - } + // bpo-42536: The GC may have untracked this result tuple. Since we're + // recycling it, make sure it's tracked again: + if (!_PyObject_GC_IS_TRACKED(result)) { + _PyObject_GC_TRACK(result); + } } else { result = PyTuple_New(tuplesize); if (result == NULL) @@ -4574,7 +4574,7 @@ zip_longest_next(ziplongestobject *lz) } static PyObject * -zip_longest_reduce(ziplongestobject *lz, PyObject *Py_UNUSED(ignored)) +zip_longest_reduce(ziplongestobject *lz, PyObject *Py_UNUSED(ignored)) { /* Create a new tuple with empty sequences where appropriate to pickle. @@ -4634,10 +4634,10 @@ static PyTypeObject ziplongest_type = { 0, /* tp_itemsize */ /* methods */ (destructor)zip_longest_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -4671,7 +4671,7 @@ static PyTypeObject ziplongest_type = { PyObject_GC_Del, /* tp_free */ }; - + /* module level code ********************************************************/ PyDoc_STRVAR(module_doc, @@ -4684,8 +4684,8 @@ repeat(elem [,n]) --> elem, elem, elem, ... endlessly or up to n times\n\ \n\ Iterators terminating on the shortest input sequence:\n\ accumulate(p[, func]) --> p0, p0+p1, p0+p1+p2\n\ -chain(p, q, ...) --> p0, p1, ... plast, q0, q1, ...\n\ -chain.from_iterable([p, q, ...]) --> p0, p1, ... plast, q0, q1, ...\n\ +chain(p, q, ...) --> p0, p1, ... plast, q0, q1, ...\n\ +chain.from_iterable([p, q, ...]) --> p0, p1, ... plast, q0, q1, ...\n\ compress(data, selectors) --> (d[0] if s[0]), (d[1] if s[1]), ...\n\ dropwhile(pred, seq) --> seq[n], seq[n+1], starting when pred fails\n\ groupby(iterable[, keyfunc]) --> sub-iterators grouped by value of keyfunc(v)\n\ @@ -4695,7 +4695,7 @@ islice(seq, [start,] stop [, step]) --> elements from\n\ starmap(fun, seq) --> fun(*seq[0]), fun(*seq[1]), ...\n\ tee(it, n=2) --> (it1, it2 , ... itn) splits one iterator into n\n\ takewhile(pred, seq) --> seq[0], seq[1], until pred fails\n\ -zip_longest(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ...\n\ +zip_longest(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ...\n\ \n\ Combinatoric generators:\n\ product(p, q, ... [repeat=1]) --> cartesian product\n\ @@ -4704,8 +4704,8 @@ combinations(p, r)\n\ combinations_with_replacement(p, r)\n\ "); -static int -itertoolsmodule_exec(PyObject *m) +static int +itertoolsmodule_exec(PyObject *m) { PyTypeObject *typelist[] = { &accumulate_type, @@ -4727,45 +4727,45 @@ itertoolsmodule_exec(PyObject *m) &groupby_type, &_grouper_type, &tee_type, - &teedataobject_type + &teedataobject_type }; - Py_SET_TYPE(&teedataobject_type, &PyType_Type); + Py_SET_TYPE(&teedataobject_type, &PyType_Type); - for (size_t i = 0; i < Py_ARRAY_LENGTH(typelist); i++) { - if (PyModule_AddType(m, typelist[i]) < 0) { - return -1; - } + for (size_t i = 0; i < Py_ARRAY_LENGTH(typelist); i++) { + if (PyModule_AddType(m, typelist[i]) < 0) { + return -1; + } } - return 0; -} - -static struct PyModuleDef_Slot itertoolsmodule_slots[] = { - {Py_mod_exec, itertoolsmodule_exec}, - {0, NULL} -}; - -static PyMethodDef module_methods[] = { - ITERTOOLS_TEE_METHODDEF - {NULL, NULL} /* sentinel */ -}; - - -static struct PyModuleDef itertoolsmodule = { - PyModuleDef_HEAD_INIT, - "itertools", - module_doc, - 0, - module_methods, - itertoolsmodule_slots, - NULL, - NULL, - NULL -}; - -PyMODINIT_FUNC -PyInit_itertools(void) -{ - return PyModuleDef_Init(&itertoolsmodule); -} + return 0; +} + +static struct PyModuleDef_Slot itertoolsmodule_slots[] = { + {Py_mod_exec, itertoolsmodule_exec}, + {0, NULL} +}; + +static PyMethodDef module_methods[] = { + ITERTOOLS_TEE_METHODDEF + {NULL, NULL} /* sentinel */ +}; + + +static struct PyModuleDef itertoolsmodule = { + PyModuleDef_HEAD_INIT, + "itertools", + module_doc, + 0, + module_methods, + itertoolsmodule_slots, + NULL, + NULL, + NULL +}; + +PyMODINIT_FUNC +PyInit_itertools(void) +{ + return PyModuleDef_Init(&itertoolsmodule); +} |