1cdef extern from "Python.h": 2 3 # PyTypeObject PySlice_Type 4 # 5 # The type object for slice objects. This is the same as slice and types.SliceType 6 7 bint PySlice_Check(object ob) 8 # 9 # Return true if ob is a slice object; ob must not be NULL. 10 11 slice PySlice_New(object start, object stop, object step) 12 # 13 # Return a new slice object with the given values. The start, stop, and step 14 # parameters are used as the values of the slice object attributes of the same 15 # names. Any of the values may be NULL, in which case the None will be used 16 # for the corresponding attribute. Return NULL if the new object could not be 17 # allocated. 18 19 int PySlice_GetIndices(object slice, Py_ssize_t length, 20 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step) except? -1 21 # 22 # Retrieve the start, stop and step indices from the slice object slice, 23 # assuming a sequence of length length. Treats indices greater than length 24 # as errors. 25 # 26 # Returns 0 on success and -1 on error with no exception set (unless one 27 # of the indices was not None and failed to be converted to an integer, 28 # in which case -1 is returned with an exception set). 29 # 30 # You probably do not want to use this function. 31 # 32 # Changed in version 3.2: The parameter type for the slice parameter was 33 # PySliceObject* before. 34 35 int PySlice_GetIndicesEx(object slice, Py_ssize_t length, 36 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, 37 Py_ssize_t *slicelength) except -1 38 # 39 # Usable replacement for PySlice_GetIndices(). Retrieve the start, stop, and step 40 # indices from the slice object slice assuming a sequence of length length, and 41 # store the length of the slice in slicelength. Out of bounds indices are clipped 42 # in a manner consistent with the handling of normal slices. 43 # 44 # Returns 0 on success and -1 on error with exception set. 45 # 46 # Changed in version 3.2: The parameter type for the slice parameter was 47 # PySliceObject* before. 48 49 int PySlice_Unpack(object slice, Py_ssize_t *start, Py_ssize_t *stop, 50 Py_ssize_t *step) except -1 51 # Extract the start, stop and step data members from a slice object as C 52 # integers. Silently reduce values larger than PY_SSIZE_T_MAX to 53 # PY_SSIZE_T_MAX, silently boost the start and stop values less than 54 # PY_SSIZE_T_MIN to PY_SSIZE_T_MIN, and silently boost the step values 55 # less than -PY_SSIZE_T_MAX to -PY_SSIZE_T_MAX. 56 57 # Return -1 on error, 0 on success. 58 59 # New in version 3.6.1. 60 61 Py_ssize_t PySlice_AdjustIndices(Py_ssize_t length, Py_ssize_t *start, 62 Py_ssize_t *stop, Py_ssize_t step) 63 # Adjust start/end slice indices assuming a sequence of the specified 64 # length. Out of bounds indices are clipped in a manner consistent with 65 # the handling of normal slices. 66 67 # Return the length of the slice. Always successful. Doesn’t call Python 68 # code. 69 70 # New in version 3.6.1. 71