Lines Matching refs:it
16 seqiterobject *it;
22 it = PyObject_GC_New(seqiterobject, &PySeqIter_Type);
23 if (it == NULL)
25 it->it_index = 0;
27 it->it_seq = seq;
28 _PyObject_GC_TRACK(it);
29 return (PyObject *)it;
33 iter_dealloc(seqiterobject *it)
35 _PyObject_GC_UNTRACK(it);
36 Py_XDECREF(it->it_seq);
37 PyObject_GC_Del(it);
41 iter_traverse(seqiterobject *it, visitproc visit, void *arg)
43 Py_VISIT(it->it_seq);
50 seqiterobject *it;
55 it = (seqiterobject *)iterator;
56 seq = it->it_seq;
59 if (it->it_index == PY_SSIZE_T_MAX) {
65 result = PySequence_GetItem(seq, it->it_index);
67 it->it_index++;
74 it->it_seq = NULL;
81 iter_len(seqiterobject *it, PyObject *Py_UNUSED(ignored))
85 if (it->it_seq) {
86 if (_PyObject_HasLen(it->it_seq)) {
87 seqsize = PySequence_Size(it->it_seq);
94 len = seqsize - it->it_index;
101 PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it)).");
104 iter_reduce(seqiterobject *it, PyObject *Py_UNUSED(ignored))
112 if (it->it_seq != NULL)
113 return Py_BuildValue("N(O)n", iter, it->it_seq, it->it_index);
121 iter_setstate(seqiterobject *it, PyObject *state)
126 if (it->it_seq != NULL) {
129 it->it_index = index;
187 calliterobject *it;
188 it = PyObject_GC_New(calliterobject, &PyCallIter_Type);
189 if (it == NULL)
192 it->it_callable = callable;
194 it->it_sentinel = sentinel;
195 _PyObject_GC_TRACK(it);
196 return (PyObject *)it;
199 calliter_dealloc(calliterobject *it)
201 _PyObject_GC_UNTRACK(it);
202 Py_XDECREF(it->it_callable);
203 Py_XDECREF(it->it_sentinel);
204 PyObject_GC_Del(it);
208 calliter_traverse(calliterobject *it, visitproc visit, void *arg)
210 Py_VISIT(it->it_callable);
211 Py_VISIT(it->it_sentinel);
216 calliter_iternext(calliterobject *it)
220 if (it->it_callable == NULL) {
224 result = _PyObject_CallNoArgs(it->it_callable);
225 if (result != NULL && it->it_sentinel != NULL){
228 ok = PyObject_RichCompareBool(it->it_sentinel, result, Py_EQ);
234 Py_CLEAR(it->it_callable);
235 Py_CLEAR(it->it_sentinel);
240 Py_CLEAR(it->it_callable);
241 Py_CLEAR(it->it_sentinel);
248 calliter_reduce(calliterobject *it, PyObject *Py_UNUSED(ignored))
256 if (it->it_callable != NULL && it->it_sentinel != NULL)
257 return Py_BuildValue("N(OO)", iter, it->it_callable, it->it_sentinel);
408 * exception we replace it with a `StopIteration(default)`, as if
409 * it was the return value of `__anext__()` coroutine.