52 Py_ssize_t sliceLength = PySlice_AdjustIndices(sequenceLength, &
start, &
stop,
step);
58 LASS_ASSERT(sliceLength == 0 &&
step < 0);
62 LASS_ASSERT(
start >= 0 &&
start <= sequenceLength);
63 LASS_ASSERT(
stop >= -1 &&
stop <= sequenceLength);
72 LASS_ASSERT(sequenceLength >= 0);
73 Py_ssize_t i = *index;
78 if (i < 0 || i >= sequenceLength)
81 PyErr_SetString(PyExc_IndexError,
"index out of range");
90Py_ssize_t
adjustIndex(Py_ssize_t index, Py_ssize_t sequenceLength)
acquire the GIL for the current scope.
void fetchAndThrowPythonException(std::string loc)
Fetch the current Python exception and throw it as a C++ PythonException.
Py_ssize_t adjustIndex(Py_ssize_t index, Py_ssize_t sequenceLength)
Helper to adjust negative sequence indices.
bool adjustIndexEx(Py_ssize_t *index, Py_ssize_t sequenceLength)
Helper to adjust negative sequence indices.
Comprehensive C++ to Python binding library.
Py_ssize_t adjustIndices(Py_ssize_t sequenceLength)
Adjust start and stop for actual sequence length, returning slice length.
Py_ssize_t step
step size of slice.
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 * st...