• Home
  • Raw
  • Download

Lines Matching full:step

109 /* start, stop, and step are python objects with None indicating no
114 PySlice_New(PyObject *start, PyObject *stop, PyObject *step) in PySlice_New() argument
116 if (step == NULL) { in PySlice_New()
117 step = Py_None; in PySlice_New()
140 Py_INCREF(step); in PySlice_New()
141 obj->step = step; in PySlice_New()
172 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step) in PySlice_GetIndices() argument
176 if (r->step == Py_None) { in PySlice_GetIndices()
177 *step = 1; in PySlice_GetIndices()
179 if (!PyLong_Check(r->step)) return -1; in PySlice_GetIndices()
180 *step = PyLong_AsSsize_t(r->step); in PySlice_GetIndices()
183 *start = *step < 0 ? length-1 : 0; in PySlice_GetIndices()
190 *stop = *step < 0 ? -1 : length; in PySlice_GetIndices()
198 if (*step == 0) return -1; in PySlice_GetIndices()
204 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step) in PySlice_Unpack() argument
212 if (r->step == Py_None) { in PySlice_Unpack()
213 *step = 1; in PySlice_Unpack()
216 if (!_PyEval_SliceIndex(r->step, step)) return -1; in PySlice_Unpack()
217 if (*step == 0) { in PySlice_Unpack()
219 "slice step cannot be zero"); in PySlice_Unpack()
222 /* Here *step might be -PY_SSIZE_T_MAX-1; in this case we replace it in PySlice_Unpack()
225 * does "step = -step" as part of a slice reversal. in PySlice_Unpack()
227 if (*step < -PY_SSIZE_T_MAX) in PySlice_Unpack()
228 *step = -PY_SSIZE_T_MAX; in PySlice_Unpack()
232 *start = *step < 0 ? PY_SSIZE_T_MAX : 0; in PySlice_Unpack()
239 *stop = *step < 0 ? PY_SSIZE_T_MIN : PY_SSIZE_T_MAX; in PySlice_Unpack()
250 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t step) in PySlice_AdjustIndices() argument
254 assert(step != 0); in PySlice_AdjustIndices()
255 assert(step >= -PY_SSIZE_T_MAX); in PySlice_AdjustIndices()
260 *start = (step < 0) ? -1 : 0; in PySlice_AdjustIndices()
264 *start = (step < 0) ? length - 1 : length; in PySlice_AdjustIndices()
270 *stop = (step < 0) ? -1 : 0; in PySlice_AdjustIndices()
274 *stop = (step < 0) ? length - 1 : length; in PySlice_AdjustIndices()
277 if (step < 0) { in PySlice_AdjustIndices()
279 return (*start - *stop - 1) / (-step) + 1; in PySlice_AdjustIndices()
284 return (*stop - *start - 1) / step + 1; in PySlice_AdjustIndices()
294 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, in PySlice_GetIndicesEx() argument
297 if (PySlice_Unpack(_r, start, stop, step) < 0) in PySlice_GetIndicesEx()
299 *slicelength = PySlice_AdjustIndices(length, start, stop, *step); in PySlice_GetIndicesEx()
306 PyObject *start, *stop, *step; in slice_new() local
308 start = stop = step = NULL; in slice_new()
313 if (!PyArg_UnpackTuple(args, "slice", 1, 3, &start, &stop, &step)) in slice_new()
322 return PySlice_New(start, stop, step); in slice_new()
327 slice(start, stop[, step])\n\
336 Py_DECREF(r->step); in slice_dealloc()
350 return PyUnicode_FromFormat("slice(%R, %R, %R)", r->start, r->stop, r->step); in slice_repr()
356 {"step", T_OBJECT, offsetof(PySliceObject, step), READONLY},
386 PyObject *start=NULL, *stop=NULL, *step=NULL; in _PySlice_GetLongIndices() local
390 /* Convert step to an integer; raise for zero step. */ in _PySlice_GetLongIndices()
391 if (self->step == Py_None) { in _PySlice_GetLongIndices()
392 step = _PyLong_GetOne(); in _PySlice_GetLongIndices()
393 Py_INCREF(step); in _PySlice_GetLongIndices()
398 step = evaluate_slice_index(self->step); in _PySlice_GetLongIndices()
399 if (step == NULL) in _PySlice_GetLongIndices()
401 step_sign = _PyLong_Sign(step); in _PySlice_GetLongIndices()
404 "slice step cannot be zero"); in _PySlice_GetLongIndices()
507 *step_ptr = step; in _PySlice_GetLongIndices()
516 Py_XDECREF(step); in _PySlice_GetLongIndices()
527 PyObject *start, *stop, *step; in slice_indices() local
543 error = _PySlice_GetLongIndices(self, length, &start, &stop, &step); in slice_indices()
548 return Py_BuildValue("(NNN)", start, stop, step); in slice_indices()
562 return Py_BuildValue("O(OOO)", Py_TYPE(self), self->start, self->stop, self->step); in slice_reduce()
603 ((PySliceObject *)v)->step); in slice_richcompare()
611 ((PySliceObject *)w)->step); in slice_richcompare()
628 Py_VISIT(v->step); in slice_traverse()