Lines Matching full:stop
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
122 if (stop == NULL) { in PySlice_New()
123 stop = Py_None; in PySlice_New()
144 Py_INCREF(stop); in PySlice_New()
145 obj->stop = stop; in PySlice_New()
172 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step) in PySlice_GetIndices() argument
189 if (r->stop == Py_None) { in PySlice_GetIndices()
190 *stop = *step < 0 ? -1 : length; in PySlice_GetIndices()
192 if (!PyLong_Check(r->stop)) return -1; in PySlice_GetIndices()
193 *stop = PyLong_AsSsize_t(r->stop); in PySlice_GetIndices()
194 if (*stop < 0) *stop += length; in PySlice_GetIndices()
196 if (*stop > length) return -1; in PySlice_GetIndices()
204 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step) in PySlice_Unpack() argument
238 if (r->stop == Py_None) { in PySlice_Unpack()
239 *stop = *step < 0 ? PY_SSIZE_T_MIN : PY_SSIZE_T_MAX; in PySlice_Unpack()
242 if (!_PyEval_SliceIndex(r->stop, stop)) return -1; in PySlice_Unpack()
250 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t step) in PySlice_AdjustIndices() argument
267 if (*stop < 0) { in PySlice_AdjustIndices()
268 *stop += length; in PySlice_AdjustIndices()
269 if (*stop < 0) { in PySlice_AdjustIndices()
270 *stop = (step < 0) ? -1 : 0; in PySlice_AdjustIndices()
273 else if (*stop >= length) { in PySlice_AdjustIndices()
274 *stop = (step < 0) ? length - 1 : length; in PySlice_AdjustIndices()
278 if (*stop < *start) { in PySlice_AdjustIndices()
279 return (*start - *stop - 1) / (-step) + 1; in PySlice_AdjustIndices()
283 if (*start < *stop) { 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()
316 /* This swapping of stop and start is to maintain similarity with in slice_new()
318 if (stop == NULL) { in slice_new()
319 stop = start; in slice_new()
322 return PySlice_New(start, stop, step); in slice_new()
326 "slice(stop)\n\
327 slice(start, stop[, step])\n\
338 Py_DECREF(r->stop); in slice_dealloc()
350 return PyUnicode_FromFormat("slice(%R, %R, %R)", r->start, r->stop, r->step); in slice_repr()
355 {"stop", T_OBJECT, offsetof(PySliceObject, stop), READONLY},
386 PyObject *start=NULL, *stop=NULL, *step=NULL; in _PySlice_GetLongIndices() local
410 /* Find lower and upper bounds for start and stop. */ in _PySlice_GetLongIndices()
466 /* Compute stop. */ in _PySlice_GetLongIndices()
467 if (self->stop == Py_None) { in _PySlice_GetLongIndices()
468 stop = step_is_negative ? lower : upper; in _PySlice_GetLongIndices()
469 Py_INCREF(stop); in _PySlice_GetLongIndices()
472 stop = evaluate_slice_index(self->stop); in _PySlice_GetLongIndices()
473 if (stop == NULL) in _PySlice_GetLongIndices()
476 if (_PyLong_Sign(stop) < 0) { in _PySlice_GetLongIndices()
477 /* stop += length */ in _PySlice_GetLongIndices()
478 PyObject *tmp = PyNumber_Add(stop, length); in _PySlice_GetLongIndices()
479 Py_DECREF(stop); in _PySlice_GetLongIndices()
480 stop = tmp; in _PySlice_GetLongIndices()
481 if (stop == NULL) in _PySlice_GetLongIndices()
484 cmp_result = PyObject_RichCompareBool(stop, lower, Py_LT); in _PySlice_GetLongIndices()
489 Py_DECREF(stop); in _PySlice_GetLongIndices()
490 stop = lower; in _PySlice_GetLongIndices()
494 cmp_result = PyObject_RichCompareBool(stop, upper, Py_GT); in _PySlice_GetLongIndices()
499 Py_DECREF(stop); in _PySlice_GetLongIndices()
500 stop = upper; in _PySlice_GetLongIndices()
506 *stop_ptr = stop; in _PySlice_GetLongIndices()
515 Py_XDECREF(stop); 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()
552 "S.indices(len) -> (start, stop, stride)\n\
554 Assuming a sequence of length len, calculate the start and stop\n\
562 return Py_BuildValue("O(OOO)", Py_TYPE(self), self->start, self->stop, self->step); in slice_reduce()
602 ((PySliceObject *)v)->stop, in slice_richcompare()
610 ((PySliceObject *)w)->stop, in slice_richcompare()
627 Py_VISIT(v->stop); in slice_traverse()