Lines Matching refs:step
17 PyObject *step; member
25 validate_step(PyObject *step) in validate_step() argument
28 if (!step) in validate_step()
31 step = PyNumber_Index(step); in validate_step()
32 if (step && _PyLong_Sign(step) == 0) { in validate_step()
35 Py_CLEAR(step); in validate_step()
38 return step; in validate_step()
42 compute_range_length(PyObject *start, PyObject *stop, PyObject *step);
46 PyObject *stop, PyObject *step) in make_range_object() argument
50 length = compute_range_length(start, stop, step); in make_range_object()
61 obj->step = step; in make_range_object()
75 PyObject *start = NULL, *stop = NULL, *step = NULL; in range_new() local
89 step = _PyLong_One; in range_new()
93 &start, &stop, &step)) in range_new()
105 step = validate_step(step); /* Caution, this can clear exceptions */ in range_new()
106 if (!step) { in range_new()
113 obj = make_range_object(type, start, stop, step); in range_new()
120 Py_DECREF(step); in range_new()
139 Py_DECREF(r->step); in range_dealloc()
149 compute_range_length(PyObject *start, PyObject *stop, PyObject *step) in compute_range_length() argument
161 cmp_result = PyObject_RichCompareBool(step, _PyLong_Zero, Py_GT); in compute_range_length()
168 Py_INCREF(step); in compute_range_length()
172 step = PyNumber_Negative(step); in compute_range_length()
173 if (!step) in compute_range_length()
180 Py_DECREF(step); in compute_range_length()
192 if ((tmp2 = PyNumber_FloorDivide(diff, step)) == NULL) in compute_range_length()
200 Py_DECREF(step); in compute_range_length()
205 Py_DECREF(step); in compute_range_length()
225 incr = PyNumber_Multiply(i, r->step); in compute_item()
302 PyObject *start = NULL, *stop = NULL, *step = NULL; in compute_slice() local
306 error = _PySlice_GetLongIndices(slice, r->length, &start, &stop, &step); in compute_slice()
310 substep = PyNumber_Multiply(r->step, step); in compute_slice()
312 Py_CLEAR(step); in compute_slice()
329 Py_XDECREF(step); in compute_slice()
347 cmp1 = PyObject_RichCompareBool(r->step, _PyLong_Zero, Py_GT); in range_contains_long()
370 tmp2 = PyNumber_Remainder(tmp1, r->step); in range_contains_long()
429 return PyObject_RichCompareBool(r0->step, r1->step, Py_EQ); in range_equals()
502 Py_INCREF(r->step); in range_hash()
503 PyTuple_SET_ITEM(t, 2, r->step); in range_hash()
551 idx = PyNumber_FloorDivide(tmp, r->step); in range_index()
579 istep = PyNumber_AsSsize_t(r->step, NULL); in range_repr()
589 r->start, r->stop, r->step); in range_repr()
597 r->start, r->stop, r->step); in range_reduce()
662 {"step", T_OBJECT_EX, offsetof(rangeobject, step), READONLY},
718 long step; member
729 (unsigned long)(r->index++) * r->step)); in rangeiter_next()
745 PyObject *start=NULL, *stop=NULL, *step=NULL; in rangeiter_reduce() local
752 stop = PyLong_FromLong(r->start + r->len * r->step); in rangeiter_reduce()
755 step = PyLong_FromLong(r->step); in rangeiter_reduce()
756 if (step == NULL) in rangeiter_reduce()
759 start, stop, step); in rangeiter_reduce()
767 Py_XDECREF(step); in rangeiter_reduce()
836 get_len_of_range(long lo, long hi, long step) in get_len_of_range() argument
851 assert(step != 0); in get_len_of_range()
852 if (step > 0 && lo < hi) in get_len_of_range()
853 return 1UL + (hi - 1UL - lo) / step; in get_len_of_range()
854 else if (step < 0 && lo > hi) in get_len_of_range()
855 return 1UL + (lo - 1UL - hi) / (0UL - step); in get_len_of_range()
864 fast_range_iter(long start, long stop, long step) in fast_range_iter() argument
871 it->step = step; in fast_range_iter()
872 ulen = get_len_of_range(start, stop, step); in fast_range_iter()
888 PyObject *step; member
905 product = PyNumber_Multiply(r->len, r->step); in longrangeiter_reduce()
913 Py_INCREF(r->step); in longrangeiter_reduce()
915 r->start, stop, r->step); in longrangeiter_reduce()
919 Py_DECREF(r->step); in longrangeiter_reduce()
966 Py_XDECREF(r->step); in longrangeiter_dealloc()
982 product = PyNumber_Multiply(r->index, r->step); in longrangeiter_next()
1055 lstep = PyLong_AsLong(r->step); in range_iter()
1073 it->step = r->step; in range_iter()
1077 Py_INCREF(it->step); in range_iter()
1114 lstep = PyLong_AsLong(range->step); in range_reverse()
1157 it->index = it->start = it->step = NULL; in range_reverse()
1167 product = PyNumber_Multiply(diff, range->step); in range_reverse()
1178 it->step = PyNumber_Negative(range->step); in range_reverse()
1179 if (!it->step) in range_reverse()