Lines Matching refs:step
116 PySlice_New(PyObject *start, PyObject *stop, PyObject *step) in PySlice_New() argument
129 if (step == NULL) step = Py_None; in PySlice_New()
130 Py_INCREF(step); in PySlice_New()
136 obj->step = step; in PySlice_New()
165 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step) in PySlice_GetIndices() argument
169 if (r->step == Py_None) { in PySlice_GetIndices()
170 *step = 1; in PySlice_GetIndices()
172 if (!PyLong_Check(r->step)) return -1; in PySlice_GetIndices()
173 *step = PyLong_AsSsize_t(r->step); in PySlice_GetIndices()
176 *start = *step < 0 ? length-1 : 0; in PySlice_GetIndices()
183 *stop = *step < 0 ? -1 : length; in PySlice_GetIndices()
191 if (*step == 0) return -1; in PySlice_GetIndices()
197 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step) in PySlice_Unpack() argument
204 if (r->step == Py_None) { in PySlice_Unpack()
205 *step = 1; in PySlice_Unpack()
208 if (!_PyEval_SliceIndex(r->step, step)) return -1; in PySlice_Unpack()
209 if (*step == 0) { in PySlice_Unpack()
219 if (*step < -PY_SSIZE_T_MAX) in PySlice_Unpack()
220 *step = -PY_SSIZE_T_MAX; in PySlice_Unpack()
224 *start = *step < 0 ? PY_SSIZE_T_MAX : 0; in PySlice_Unpack()
231 *stop = *step < 0 ? PY_SSIZE_T_MIN : PY_SSIZE_T_MAX; in PySlice_Unpack()
242 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t step) in PySlice_AdjustIndices() argument
246 assert(step != 0); in PySlice_AdjustIndices()
247 assert(step >= -PY_SSIZE_T_MAX); in PySlice_AdjustIndices()
252 *start = (step < 0) ? -1 : 0; in PySlice_AdjustIndices()
256 *start = (step < 0) ? length - 1 : length; in PySlice_AdjustIndices()
262 *stop = (step < 0) ? -1 : 0; in PySlice_AdjustIndices()
266 *stop = (step < 0) ? length - 1 : length; in PySlice_AdjustIndices()
269 if (step < 0) { in PySlice_AdjustIndices()
271 return (*start - *stop - 1) / (-step) + 1; in PySlice_AdjustIndices()
276 return (*stop - *start - 1) / step + 1; in PySlice_AdjustIndices()
286 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, in PySlice_GetIndicesEx() argument
289 if (PySlice_Unpack(_r, start, stop, step) < 0) in PySlice_GetIndicesEx()
291 *slicelength = PySlice_AdjustIndices(length, start, stop, *step); in PySlice_GetIndicesEx()
298 PyObject *start, *stop, *step; in slice_new() local
300 start = stop = step = NULL; in slice_new()
305 if (!PyArg_UnpackTuple(args, "slice", 1, 3, &start, &stop, &step)) in slice_new()
314 return PySlice_New(start, stop, step); in slice_new()
327 Py_DECREF(r->step); in slice_dealloc()
339 return PyUnicode_FromFormat("slice(%R, %R, %R)", r->start, r->stop, r->step); in slice_repr()
345 {"step", T_OBJECT, offsetof(PySliceObject, step), READONLY},
375 PyObject *start=NULL, *stop=NULL, *step=NULL; in _PySlice_GetLongIndices() local
380 if (self->step == Py_None) { in _PySlice_GetLongIndices()
381 step = _PyLong_One; in _PySlice_GetLongIndices()
382 Py_INCREF(step); in _PySlice_GetLongIndices()
387 step = evaluate_slice_index(self->step); in _PySlice_GetLongIndices()
388 if (step == NULL) in _PySlice_GetLongIndices()
390 step_sign = _PyLong_Sign(step); in _PySlice_GetLongIndices()
496 *step_ptr = step; in _PySlice_GetLongIndices()
505 Py_XDECREF(step); in _PySlice_GetLongIndices()
516 PyObject *start, *stop, *step; in slice_indices() local
532 error = _PySlice_GetLongIndices(self, length, &start, &stop, &step); in slice_indices()
537 return Py_BuildValue("(NNN)", start, stop, step); in slice_indices()
551 return Py_BuildValue("O(OOO)", Py_TYPE(self), self->start, self->stop, self->step); in slice_reduce()
592 ((PySliceObject *)v)->step); in slice_richcompare()
600 ((PySliceObject *)w)->step); in slice_richcompare()
617 Py_VISIT(v->step); in slice_traverse()