Lines Matching refs:start
114 PySlice_New(PyObject *start, PyObject *stop, PyObject *step) in PySlice_New() argument
119 if (start == NULL) { in PySlice_New()
120 start = Py_None; in PySlice_New()
142 Py_INCREF(start); in PySlice_New()
143 obj->start = start; in PySlice_New()
154 PyObject *start, *end, *slice; in _PySlice_FromIndices() local
155 start = PyLong_FromSsize_t(istart); in _PySlice_FromIndices()
156 if (!start) in _PySlice_FromIndices()
160 Py_DECREF(start); in _PySlice_FromIndices()
164 slice = PySlice_New(start, end, NULL); in _PySlice_FromIndices()
165 Py_DECREF(start); in _PySlice_FromIndices()
172 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step) in PySlice_GetIndices() argument
182 if (r->start == Py_None) { in PySlice_GetIndices()
183 *start = *step < 0 ? length-1 : 0; in PySlice_GetIndices()
185 if (!PyLong_Check(r->start)) return -1; in PySlice_GetIndices()
186 *start = PyLong_AsSsize_t(r->start); in PySlice_GetIndices()
187 if (*start < 0) *start += length; in PySlice_GetIndices()
197 if (*start >= length) return -1; in PySlice_GetIndices()
204 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step) in PySlice_Unpack() argument
230 if (r->start == Py_None) { in PySlice_Unpack()
231 *start = *step < 0 ? PY_SSIZE_T_MAX : 0; in PySlice_Unpack()
234 if (!_PyEval_SliceIndex(r->start, start)) return -1; in PySlice_Unpack()
249 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t step) in PySlice_AdjustIndices() argument
256 if (*start < 0) { in PySlice_AdjustIndices()
257 *start += length; in PySlice_AdjustIndices()
258 if (*start < 0) { in PySlice_AdjustIndices()
259 *start = (step < 0) ? -1 : 0; in PySlice_AdjustIndices()
262 else if (*start >= length) { in PySlice_AdjustIndices()
263 *start = (step < 0) ? length - 1 : length; in PySlice_AdjustIndices()
277 if (*stop < *start) { in PySlice_AdjustIndices()
278 return (*start - *stop - 1) / (-step) + 1; in PySlice_AdjustIndices()
282 if (*start < *stop) { in PySlice_AdjustIndices()
283 return (*stop - *start - 1) / step + 1; in PySlice_AdjustIndices()
293 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, in PySlice_GetIndicesEx() argument
296 if (PySlice_Unpack(_r, start, stop, step) < 0) in PySlice_GetIndicesEx()
298 *slicelength = PySlice_AdjustIndices(length, start, stop, *step); in PySlice_GetIndicesEx()
305 PyObject *start, *stop, *step; in slice_new() local
307 start = stop = step = NULL; in slice_new()
312 if (!PyArg_UnpackTuple(args, "slice", 1, 3, &start, &stop, &step)) in slice_new()
318 stop = start; in slice_new()
319 start = NULL; in slice_new()
321 return PySlice_New(start, stop, step); in slice_new()
336 Py_DECREF(r->start); in slice_dealloc()
349 return PyUnicode_FromFormat("slice(%R, %R, %R)", r->start, r->stop, r->step); in slice_repr()
353 {"start", T_OBJECT, offsetof(PySliceObject, start), READONLY},
385 PyObject *start=NULL, *stop=NULL, *step=NULL; in _PySlice_GetLongIndices() local
427 if (self->start == Py_None) { in _PySlice_GetLongIndices()
428 start = step_is_negative ? upper : lower; in _PySlice_GetLongIndices()
429 Py_INCREF(start); in _PySlice_GetLongIndices()
432 start = evaluate_slice_index(self->start); in _PySlice_GetLongIndices()
433 if (start == NULL) in _PySlice_GetLongIndices()
436 if (_PyLong_Sign(start) < 0) { in _PySlice_GetLongIndices()
438 PyObject *tmp = PyNumber_Add(start, length); in _PySlice_GetLongIndices()
439 Py_DECREF(start); in _PySlice_GetLongIndices()
440 start = tmp; in _PySlice_GetLongIndices()
441 if (start == NULL) in _PySlice_GetLongIndices()
444 cmp_result = PyObject_RichCompareBool(start, lower, Py_LT); in _PySlice_GetLongIndices()
449 Py_DECREF(start); in _PySlice_GetLongIndices()
450 start = lower; in _PySlice_GetLongIndices()
454 cmp_result = PyObject_RichCompareBool(start, upper, Py_GT); in _PySlice_GetLongIndices()
459 Py_DECREF(start); in _PySlice_GetLongIndices()
460 start = upper; in _PySlice_GetLongIndices()
504 *start_ptr = start; in _PySlice_GetLongIndices()
513 Py_XDECREF(start); in _PySlice_GetLongIndices()
526 PyObject *start, *stop, *step; in slice_indices() local
542 error = _PySlice_GetLongIndices(self, length, &start, &stop, &step); in slice_indices()
547 return Py_BuildValue("(NNN)", start, stop, step); in slice_indices()
561 return Py_BuildValue("O(OOO)", Py_TYPE(self), self->start, self->stop, self->step); in slice_reduce()
600 ((PySliceObject *)v)->start, in slice_richcompare()
608 ((PySliceObject *)w)->start, in slice_richcompare()
625 Py_VISIT(v->start); in slice_traverse()