1
1
import cython
2
2
from cython import Py_ssize_t
3
3
4
- from cpython.object cimport PyObject
4
+ from cpython.slice cimport PySlice_GetIndicesEx
5
5
6
6
cdef extern from " Python.h" :
7
7
Py_ssize_t PY_SSIZE_T_MAX
8
8
9
9
import numpy as np
10
10
from numpy cimport int64_t
11
11
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
-
19
12
from pandas._libs.algos import ensure_int64
20
13
21
14
@@ -258,8 +251,8 @@ cpdef Py_ssize_t slice_len(
258
251
if slc is None :
259
252
raise TypeError (" slc must be slice" )
260
253
261
- slice_get_indices( < PyObject * > slc, objlen,
262
- & start, & stop, & step, & length)
254
+ PySlice_GetIndicesEx( slc, objlen,
255
+ & start, & stop, & step, & length)
263
256
264
257
return length
265
258
@@ -278,8 +271,8 @@ cdef slice_get_indices_ex(slice slc, Py_ssize_t objlen=PY_SSIZE_T_MAX):
278
271
if slc is None :
279
272
raise TypeError (" slc should be a slice" )
280
273
281
- slice_get_indices( < PyObject * > slc, objlen,
282
- & start, & stop, & step, & length)
274
+ PySlice_GetIndicesEx( slc, objlen,
275
+ & start, & stop, & step, & length)
283
276
284
277
return start, stop, step, length
285
278
0 commit comments