Lines Matching refs:step

117 PySlice_New(PyObject *start, PyObject *stop, PyObject *step)  in PySlice_New()  argument
130 if (step == NULL) step = Py_None; in PySlice_New()
131 Py_INCREF(step); in PySlice_New()
137 obj->step = step; in PySlice_New()
166 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step) in PySlice_GetIndices() argument
170 if (r->step == Py_None) { in PySlice_GetIndices()
171 *step = 1; in PySlice_GetIndices()
173 if (!PyLong_Check(r->step)) return -1; in PySlice_GetIndices()
174 *step = PyLong_AsSsize_t(r->step); in PySlice_GetIndices()
177 *start = *step < 0 ? length-1 : 0; in PySlice_GetIndices()
184 *stop = *step < 0 ? -1 : length; in PySlice_GetIndices()
192 if (*step == 0) return -1; in PySlice_GetIndices()
198 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step) in PySlice_Unpack() argument
205 if (r->step == Py_None) { in PySlice_Unpack()
206 *step = 1; in PySlice_Unpack()
209 if (!_PyEval_SliceIndex(r->step, step)) return -1; in PySlice_Unpack()
210 if (*step == 0) { in PySlice_Unpack()
220 if (*step < -PY_SSIZE_T_MAX) in PySlice_Unpack()
221 *step = -PY_SSIZE_T_MAX; in PySlice_Unpack()
225 *start = *step < 0 ? PY_SSIZE_T_MAX : 0; in PySlice_Unpack()
232 *stop = *step < 0 ? PY_SSIZE_T_MIN : PY_SSIZE_T_MAX; in PySlice_Unpack()
243 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t step) in PySlice_AdjustIndices() argument
247 assert(step != 0); in PySlice_AdjustIndices()
248 assert(step >= -PY_SSIZE_T_MAX); in PySlice_AdjustIndices()
253 *start = (step < 0) ? -1 : 0; in PySlice_AdjustIndices()
257 *start = (step < 0) ? length - 1 : length; in PySlice_AdjustIndices()
263 *stop = (step < 0) ? -1 : 0; in PySlice_AdjustIndices()
267 *stop = (step < 0) ? length - 1 : length; in PySlice_AdjustIndices()
270 if (step < 0) { in PySlice_AdjustIndices()
272 return (*start - *stop - 1) / (-step) + 1; in PySlice_AdjustIndices()
277 return (*stop - *start - 1) / step + 1; in PySlice_AdjustIndices()
287 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, in PySlice_GetIndicesEx() argument
290 if (PySlice_Unpack(_r, start, stop, step) < 0) in PySlice_GetIndicesEx()
292 *slicelength = PySlice_AdjustIndices(length, start, stop, *step); in PySlice_GetIndicesEx()
299 PyObject *start, *stop, *step; in slice_new() local
301 start = stop = step = NULL; in slice_new()
306 if (!PyArg_UnpackTuple(args, "slice", 1, 3, &start, &stop, &step)) in slice_new()
315 return PySlice_New(start, stop, step); in slice_new()
328 Py_DECREF(r->step); in slice_dealloc()
340 return PyUnicode_FromFormat("slice(%R, %R, %R)", r->start, r->stop, r->step); in slice_repr()
346 {"step", T_OBJECT, offsetof(PySliceObject, step), READONLY},
376 PyObject *start=NULL, *stop=NULL, *step=NULL; in _PySlice_GetLongIndices() local
381 if (self->step == Py_None) { in _PySlice_GetLongIndices()
382 step = _PyLong_One; in _PySlice_GetLongIndices()
383 Py_INCREF(step); in _PySlice_GetLongIndices()
388 step = evaluate_slice_index(self->step); in _PySlice_GetLongIndices()
389 if (step == NULL) in _PySlice_GetLongIndices()
391 step_sign = _PyLong_Sign(step); in _PySlice_GetLongIndices()
497 *step_ptr = step; in _PySlice_GetLongIndices()
506 Py_XDECREF(step); in _PySlice_GetLongIndices()
517 PyObject *start, *stop, *step; in slice_indices() local
533 error = _PySlice_GetLongIndices(self, length, &start, &stop, &step); in slice_indices()
538 return Py_BuildValue("(NNN)", start, stop, step); in slice_indices()
552 return Py_BuildValue("O(OOO)", Py_TYPE(self), self->start, self->stop, self->step); in slice_reduce()
593 ((PySliceObject *)v)->step); in slice_richcompare()
601 ((PySliceObject *)w)->step); in slice_richcompare()
618 Py_VISIT(v->step); in slice_traverse()