11import cython
22from cython import Py_ssize_t
33
4- from cpython.object cimport PyObject
4+ from cpython.slice cimport PySlice_GetIndicesEx
55
66cdef extern from " Python.h" :
77 Py_ssize_t PY_SSIZE_T_MAX
88
99import numpy as np
1010from numpy cimport int64_t
1111
12- cdef extern from " compat_helper.h" :
13- cdef int slice_get_indices(PyObject* s, Py_ssize_t length,
14- Py_ssize_t * start, Py_ssize_t * stop,
15- Py_ssize_t * step,
16- Py_ssize_t * slicelength) except - 1
17-
18-
1912from pandas._libs.algos import ensure_int64
2013
2114
@@ -258,8 +251,8 @@ cpdef Py_ssize_t slice_len(
258251 if slc is None :
259252 raise TypeError (" slc must be slice" )
260253
261- slice_get_indices( < PyObject * > slc, objlen,
262- & start, & stop, & step, & length)
254+ PySlice_GetIndicesEx( slc, objlen,
255+ & start, & stop, & step, & length)
263256
264257 return length
265258
@@ -278,8 +271,8 @@ cdef slice_get_indices_ex(slice slc, Py_ssize_t objlen=PY_SSIZE_T_MAX):
278271 if slc is None :
279272 raise TypeError (" slc should be a slice" )
280273
281- slice_get_indices( < PyObject * > slc, objlen,
282- & start, & stop, & step, & length)
274+ PySlice_GetIndicesEx( slc, objlen,
275+ & start, & stop, & step, & length)
283276
284277 return start, stop, step, length
285278
0 commit comments