#include "Python.h"
#include "pycore_call.h"
#include "pycore_ceval.h"
#include "pycore_critical_section.h"
#include "pycore_long.h"
#include "pycore_moduleobject.h"
#include "pycore_typeobject.h"
#include "pycore_object.h"
#include "pycore_tuple.h"
#include <stddef.h>
itertools_state;
static inline itertools_state *
get_module_state(PyObject *mod)
{ … }
static inline itertools_state *
get_module_state_by_cls(PyTypeObject *cls)
{ … }
static struct PyModuleDef itertoolsmodule;
static inline itertools_state *
find_state_by_type(PyTypeObject *tp)
{ … }
#define clinic_state …
#define clinic_state_by_cls …
#include "clinic/itertoolsmodule.c.h"
#undef clinic_state_by_cls
#undef clinic_state
batchedobject;
static PyObject *
batched_new_impl(PyTypeObject *type, PyObject *iterable, Py_ssize_t n,
int strict)
{ … }
static void
batched_dealloc(batchedobject *bo)
{ … }
static int
batched_traverse(batchedobject *bo, visitproc visit, void *arg)
{ … }
static PyObject *
batched_next(batchedobject *bo)
{ … }
static PyType_Slot batched_slots[] = …;
static PyType_Spec batched_spec = …;
pairwiseobject;
static PyObject *
pairwise_new_impl(PyTypeObject *type, PyObject *iterable)
{ … }
static void
pairwise_dealloc(pairwiseobject *po)
{ … }
static int
pairwise_traverse(pairwiseobject *po, visitproc visit, void *arg)
{ … }
static PyObject *
pairwise_next(pairwiseobject *po)
{ … }
static PyType_Slot pairwise_slots[] = …;
static PyType_Spec pairwise_spec = …;
groupbyobject;
static PyObject *_grouper_create(groupbyobject *, PyObject *);
static PyObject *
itertools_groupby_impl(PyTypeObject *type, PyObject *it, PyObject *keyfunc)
{ … }
static void
groupby_dealloc(groupbyobject *gbo)
{ … }
static int
groupby_traverse(groupbyobject *gbo, visitproc visit, void *arg)
{ … }
Py_LOCAL_INLINE(int)
groupby_step(groupbyobject *gbo)
{ … }
static PyObject *
groupby_next(groupbyobject *gbo)
{ … }
static PyType_Slot groupby_slots[] = …;
static PyType_Spec groupby_spec = …;
_grouperobject;
static PyObject *
itertools__grouper_impl(PyTypeObject *type, PyObject *parent,
PyObject *tgtkey)
{ … }
static PyObject *
_grouper_create(groupbyobject *parent, PyObject *tgtkey)
{ … }
static void
_grouper_dealloc(_grouperobject *igo)
{ … }
static int
_grouper_traverse(_grouperobject *igo, visitproc visit, void *arg)
{ … }
static PyObject *
_grouper_next(_grouperobject *igo)
{ … }
static PyType_Slot _grouper_slots[] = …;
static PyType_Spec _grouper_spec = …;
#define LINKCELLS …
teedataobject;
teeobject;
static PyObject *
teedataobject_newinternal(itertools_state *state, PyObject *it)
{ … }
static PyObject *
teedataobject_jumplink(itertools_state *state, teedataobject *tdo)
{ … }
static PyObject *
teedataobject_getitem(teedataobject *tdo, int i)
{ … }
static int
teedataobject_traverse(teedataobject *tdo, visitproc visit, void * arg)
{ … }
static void
teedataobject_safe_decref(PyObject *obj)
{ … }
static int
teedataobject_clear(teedataobject *tdo)
{ … }
static void
teedataobject_dealloc(teedataobject *tdo)
{ … }
static PyObject *
itertools_teedataobject_impl(PyTypeObject *type, PyObject *it,
PyObject *values, PyObject *next)
{ … }
static PyType_Slot teedataobject_slots[] = …;
static PyType_Spec teedataobject_spec = …;
static PyObject *
tee_next(teeobject *to)
{ … }
static int
tee_traverse(teeobject *to, visitproc visit, void *arg)
{ … }
static PyObject *
tee_copy(teeobject *to, PyObject *Py_UNUSED(ignored))
{ … }
PyDoc_STRVAR(teecopy_doc, "Returns an independent iterator.");
static PyObject *
tee_fromiterable(itertools_state *state, PyObject *iterable)
{ … }
static PyObject *
itertools__tee_impl(PyTypeObject *type, PyObject *iterable)
{ … }
static int
tee_clear(teeobject *to)
{ … }
static void
tee_dealloc(teeobject *to)
{ … }
static PyMethodDef tee_methods[] = …;
static PyMemberDef tee_members[] = …;
static PyType_Slot tee_slots[] = …;
static PyType_Spec tee_spec = …;
static PyObject *
itertools_tee_impl(PyObject *module, PyObject *iterable, Py_ssize_t n)
{ … }
cycleobject;
static PyObject *
itertools_cycle_impl(PyTypeObject *type, PyObject *iterable)
{ … }
static void
cycle_dealloc(cycleobject *lz)
{ … }
static int
cycle_traverse(cycleobject *lz, visitproc visit, void *arg)
{ … }
static PyObject *
cycle_next(cycleobject *lz)
{ … }
static PyType_Slot cycle_slots[] = …;
static PyType_Spec cycle_spec = …;
dropwhileobject;
static PyObject *
itertools_dropwhile_impl(PyTypeObject *type, PyObject *func, PyObject *seq)
{ … }
static void
dropwhile_dealloc(dropwhileobject *lz)
{ … }
static int
dropwhile_traverse(dropwhileobject *lz, visitproc visit, void *arg)
{ … }
static PyObject *
dropwhile_next(dropwhileobject *lz)
{ … }
static PyType_Slot dropwhile_slots[] = …;
static PyType_Spec dropwhile_spec = …;
takewhileobject;
static PyObject *
itertools_takewhile_impl(PyTypeObject *type, PyObject *func, PyObject *seq)
{ … }
static void
takewhile_dealloc(takewhileobject *lz)
{ … }
static int
takewhile_traverse(takewhileobject *lz, visitproc visit, void *arg)
{ … }
static PyObject *
takewhile_next(takewhileobject *lz)
{ … }
static PyType_Slot takewhile_slots[] = …;
static PyType_Spec takewhile_spec = …;
isliceobject;
static PyObject *
islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{ … }
static void
islice_dealloc(isliceobject *lz)
{ … }
static int
islice_traverse(isliceobject *lz, visitproc visit, void *arg)
{ … }
static PyObject *
islice_next(isliceobject *lz)
{ … }
PyDoc_STRVAR(islice_doc,
"islice(iterable, stop) --> islice object\n\
islice(iterable, start, stop[, step]) --> islice object\n\
\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\
skipped between successive calls. Works like a slice() on a list\n\
but returns an iterator.");
static PyType_Slot islice_slots[] = …;
static PyType_Spec islice_spec = …;
starmapobject;
static PyObject *
itertools_starmap_impl(PyTypeObject *type, PyObject *func, PyObject *seq)
{ … }
static void
starmap_dealloc(starmapobject *lz)
{ … }
static int
starmap_traverse(starmapobject *lz, visitproc visit, void *arg)
{ … }
static PyObject *
starmap_next(starmapobject *lz)
{ … }
static PyType_Slot starmap_slots[] = …;
static PyType_Spec starmap_spec = …;
chainobject;
static PyObject *
chain_new_internal(PyTypeObject *type, PyObject *source)
{ … }
static PyObject *
chain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{ … }
static PyObject *
itertools_chain_from_iterable(PyTypeObject *type, PyObject *arg)
{ … }
static void
chain_dealloc(chainobject *lz)
{ … }
static int
chain_traverse(chainobject *lz, visitproc visit, void *arg)
{ … }
static PyObject *
chain_next(chainobject *lz)
{ … }
PyDoc_STRVAR(chain_doc,
"chain(*iterables)\n\
--\n\
\n\
Return a chain object whose .__next__() method returns elements from the\n\
first iterable until it is exhausted, then elements from the next\n\
iterable, until all of the iterables are exhausted.");
static PyMethodDef chain_methods[] = …;
static PyType_Slot chain_slots[] = …;
static PyType_Spec chain_spec = …;
productobject;
static PyObject *
product_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{ … }
static void
product_dealloc(productobject *lz)
{ … }
static PyObject *
product_sizeof(productobject *lz, void *unused)
{ … }
PyDoc_STRVAR(sizeof_doc, "Returns size in memory, in bytes.");
static int
product_traverse(productobject *lz, visitproc visit, void *arg)
{ … }
static PyObject *
product_next(productobject *lz)
{ … }
static PyMethodDef product_methods[] = …;
PyDoc_STRVAR(product_doc,
"product(*iterables, repeat=1)\n\
--\n\
\n\
Cartesian product of input iterables. Equivalent to nested for-loops.\n\n\
For example, product(A, B) returns the same as: ((x,y) for x in A for y in B).\n\
The leftmost iterators are in the outermost for-loop, so the output tuples\n\
cycle in a manner similar to an odometer (with the rightmost element changing\n\
on every iteration).\n\n\
To compute the product of an iterable with itself, specify the number\n\
of repetitions with the optional repeat keyword argument. For example,\n\
product(A, repeat=4) means the same as product(A, A, A, A).\n\n\
product('ab', range(3)) --> ('a',0) ('a',1) ('a',2) ('b',0) ('b',1) ('b',2)\n\
product((0,1), (0,1), (0,1)) --> (0,0,0) (0,0,1) (0,1,0) (0,1,1) (1,0,0) ...");
static PyType_Slot product_slots[] = …;
static PyType_Spec product_spec = …;
combinationsobject;
static PyObject *
itertools_combinations_impl(PyTypeObject *type, PyObject *iterable,
Py_ssize_t r)
{ … }
static void
combinations_dealloc(combinationsobject *co)
{ … }
static PyObject *
combinations_sizeof(combinationsobject *co, void *unused)
{ … }
static int
combinations_traverse(combinationsobject *co, visitproc visit, void *arg)
{ … }
static PyObject *
combinations_next(combinationsobject *co)
{ … }
static PyMethodDef combinations_methods[] = …;
static PyType_Slot combinations_slots[] = …;
static PyType_Spec combinations_spec = …;
cwrobject;
static PyObject *
itertools_combinations_with_replacement_impl(PyTypeObject *type,
PyObject *iterable,
Py_ssize_t r)
{ … }
static void
cwr_dealloc(cwrobject *co)
{ … }
static PyObject *
cwr_sizeof(cwrobject *co, void *unused)
{ … }
static int
cwr_traverse(cwrobject *co, visitproc visit, void *arg)
{ … }
static PyObject *
cwr_next(cwrobject *co)
{ … }
static PyMethodDef cwr_methods[] = …;
static PyType_Slot cwr_slots[] = …;
static PyType_Spec cwr_spec = …;
permutationsobject;
static PyObject *
itertools_permutations_impl(PyTypeObject *type, PyObject *iterable,
PyObject *robj)
{ … }
static void
permutations_dealloc(permutationsobject *po)
{ … }
static PyObject *
permutations_sizeof(permutationsobject *po, void *unused)
{ … }
static int
permutations_traverse(permutationsobject *po, visitproc visit, void *arg)
{ … }
static PyObject *
permutations_next(permutationsobject *po)
{ … }
static PyMethodDef permuations_methods[] = …;
static PyType_Slot permutations_slots[] = …;
static PyType_Spec permutations_spec = …;
accumulateobject;
static PyObject *
itertools_accumulate_impl(PyTypeObject *type, PyObject *iterable,
PyObject *binop, PyObject *initial)
{ … }
static void
accumulate_dealloc(accumulateobject *lz)
{ … }
static int
accumulate_traverse(accumulateobject *lz, visitproc visit, void *arg)
{ … }
static PyObject *
accumulate_next(accumulateobject *lz)
{ … }
static PyType_Slot accumulate_slots[] = …;
static PyType_Spec accumulate_spec = …;
compressobject;
static PyObject *
itertools_compress_impl(PyTypeObject *type, PyObject *seq1, PyObject *seq2)
{ … }
static void
compress_dealloc(compressobject *lz)
{ … }
static int
compress_traverse(compressobject *lz, visitproc visit, void *arg)
{ … }
static PyObject *
compress_next(compressobject *lz)
{ … }
static PyType_Slot compress_slots[] = …;
static PyType_Spec compress_spec = …;
filterfalseobject;
static PyObject *
itertools_filterfalse_impl(PyTypeObject *type, PyObject *func, PyObject *seq)
{ … }
static void
filterfalse_dealloc(filterfalseobject *lz)
{ … }
static int
filterfalse_traverse(filterfalseobject *lz, visitproc visit, void *arg)
{ … }
static PyObject *
filterfalse_next(filterfalseobject *lz)
{ … }
static PyType_Slot filterfalse_slots[] = …;
static PyType_Spec filterfalse_spec = …;
countobject;
static PyObject *
itertools_count_impl(PyTypeObject *type, PyObject *long_cnt,
PyObject *long_step)
{ … }
static void
count_dealloc(countobject *lz)
{ … }
static int
count_traverse(countobject *lz, visitproc visit, void *arg)
{ … }
static PyObject *
count_nextlong(countobject *lz)
{ … }
static PyObject *
count_next(countobject *lz)
{ … }
static PyObject *
count_repr(countobject *lz)
{ … }
static PyType_Slot count_slots[] = …;
static PyType_Spec count_spec = …;
repeatobject;
static PyObject *
repeat_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{ … }
static void
repeat_dealloc(repeatobject *ro)
{ … }
static int
repeat_traverse(repeatobject *ro, visitproc visit, void *arg)
{ … }
static PyObject *
repeat_next(repeatobject *ro)
{ … }
static PyObject *
repeat_repr(repeatobject *ro)
{ … }
static PyObject *
repeat_len(repeatobject *ro, PyObject *Py_UNUSED(ignored))
{ … }
PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it)).");
static PyMethodDef repeat_methods[] = …;
PyDoc_STRVAR(repeat_doc,
"repeat(object [,times]) -> create an iterator which returns the object\n\
for the specified number of times. If not specified, returns the object\n\
endlessly.");
static PyType_Slot repeat_slots[] = …;
static PyType_Spec repeat_spec = …;
ziplongestobject;
static PyObject *
zip_longest_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{ … }
static void
zip_longest_dealloc(ziplongestobject *lz)
{ … }
static int
zip_longest_traverse(ziplongestobject *lz, visitproc visit, void *arg)
{ … }
static PyObject *
zip_longest_next(ziplongestobject *lz)
{ … }
PyDoc_STRVAR(zip_longest_doc,
"zip_longest(*iterables, fillvalue=None)\n\
--\n\
\n\
Return a zip_longest object whose .__next__() method returns a tuple where\n\
the i-th element comes from the i-th iterable argument. The .__next__()\n\
method continues until the longest iterable in the argument sequence\n\
is exhausted and then it raises StopIteration. When the shorter iterables\n\
are exhausted, the fillvalue is substituted in their place. The fillvalue\n\
defaults to None or can be specified by a keyword argument.\n\
");
static PyType_Slot ziplongest_slots[] = …;
static PyType_Spec ziplongest_spec = …;
PyDoc_STRVAR(module_doc,
"Functional tools for creating and using iterators.\n\
\n\
Infinite iterators:\n\
count(start=0, step=1) --> start, start+step, start+2*step, ...\n\
cycle(p) --> p0, p1, ... plast, p0, p1, ...\n\
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\
batched(p, n) --> [p0, p1, ..., p_n-1], [p_n, p_n+1, ..., p_2n-1], ...\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(predicate, seq) --> seq[n], seq[n+1], starting when predicate fails\n\
groupby(iterable[, keyfunc]) --> sub-iterators grouped by value of keyfunc(v)\n\
filterfalse(predicate, seq) --> elements of seq where predicate(elem) is False\n\
islice(seq, [start,] stop [, step]) --> elements from\n\
seq[start:stop:step]\n\
pairwise(s) --> (s[0],s[1]), (s[1],s[2]), (s[2], s[3]), ...\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(predicate, seq) --> seq[0], seq[1], until predicate fails\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\
permutations(p[, r])\n\
combinations(p, r)\n\
combinations_with_replacement(p, r)\n\
");
static int
itertoolsmodule_traverse(PyObject *mod, visitproc visit, void *arg)
{ … }
static int
itertoolsmodule_clear(PyObject *mod)
{ … }
static void
itertoolsmodule_free(void *mod)
{ … }
#define ADD_TYPE(module, type, spec) …
static int
itertoolsmodule_exec(PyObject *mod)
{ … }
static struct PyModuleDef_Slot itertoolsmodule_slots[] = …;
static PyMethodDef module_methods[] = …;
static struct PyModuleDef itertoolsmodule = …;
PyMODINIT_FUNC
PyInit_itertools(void)
{ … }