Slice Objects

PyTypeObjectPySlice_Type

The type object for slice objects. This is the same asslice in thePython layer.

intPySlice_Check(PyObject *ob)

Return true ifob is a slice object;ob must not beNULL.

PyObject*PySlice_New(PyObject *start,PyObject *stop,PyObject *step)
Return value: New reference.

Return a new slice object with the given values. Thestart,stop, andstep parameters are used as the values of the slice object attributes ofthe same names. Any of the values may beNULL, in which case theNone will be used for the corresponding attribute. ReturnNULL ifthe new object could not be allocated.

intPySlice_GetIndices(PyObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step)

Retrieve the start, stop and step indices from the slice objectslice,assuming a sequence of lengthlength. Treats indices greater thanlength as errors.

Returns0 on success and-1 on error with no exception set (unless one ofthe indices was notNone and failed to be converted to an integer,in which case-1 is returned with an exception set).

You probably do not want to use this function.

Changed in version 3.2:The parameter type for theslice parameter wasPySliceObject*before.

intPySlice_GetIndicesEx(PyObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, Py_ssize_t *slicelength)

Usable replacement forPySlice_GetIndices(). Retrieve the start,stop, and step indices from the slice objectslice assuming a sequence oflengthlength, and store the length of the slice inslicelength. Outof bounds indices are clipped in a manner consistent with the handling ofnormal slices.

Returns0 on success and-1 on error with exception set.

Changed in version 3.2:The parameter type for theslice parameter wasPySliceObject*before.

Ellipsis Object

PyObject *Py_Ellipsis

The PythonEllipsis object. This object has no methods. It needs to betreated just like any other object with respect to reference counts. LikePy_None it is a singleton object.