Helper type to get or return Python slice objects. More...
#include <subscript.h>
Public Member Functions | |
| Py_ssize_t | adjustIndices (Py_ssize_t sequenceLength) |
| Adjust start and stop for actual sequence length, returning slice length. | |
Public Attributes | |
| Py_ssize_t | start |
| start index of slice. Always the index of a valid iterator after calling adjustIndices() | |
| Py_ssize_t | stop |
stop index of slice. Can be -1 if step < 0! It's not guaranteed that stop == start + sliceLength * step | |
| Py_ssize_t | step |
| step size of slice. | |
Helper type to get or return Python slice objects.
This helper can be used as C++ parameter type to overload __getitem__ to support Python slice objects.
See Subscript Protocol for more details and examples.
Definition at line 192 of file subscript.h.
| Py_ssize_t lass::python::Slice::adjustIndices | ( | Py_ssize_t | sequenceLength | ) |
Adjust start and stop for actual sequence length, returning slice length.
| sequenceLength | actual length of the sequence to be sliced |
sliceLength, actual number of elements in slicePySlice_AdjustIndices, start will never be -1 (that case, which only happens when sliceLength == 0 and step < 0, is normalized to start = stop = 0).sequenceLength >= 0 step != 0 start >= 0 && start <= sequenceLength stop >= -1 && stop <= sequenceLength Definition at line 50 of file subscript.cpp.