3
3
cimport cython
4
4
from cython cimport Py_ssize_t
5
5
6
- from cpython cimport PyObject
6
+ from cpython cimport PyObject, PyInt_Check
7
+ from cpython.slice cimport PySlice_Check
7
8
8
9
import numpy as np
9
10
cimport numpy as np
@@ -33,7 +34,7 @@ cdef class BlockPlacement:
33
34
self ._has_slice = False
34
35
self ._has_array = False
35
36
36
- if isinstance (val, slice ):
37
+ if PySlice_Check (val):
37
38
slc = slice_canonize(val)
38
39
39
40
if slc.start != slc.stop:
@@ -127,7 +128,7 @@ cdef class BlockPlacement:
127
128
else :
128
129
val = self ._as_array[loc]
129
130
130
- if not isinstance (val, slice ) and val.ndim == 0 :
131
+ if not PySlice_Check (val) and val.ndim == 0 :
131
132
return val
132
133
133
134
return BlockPlacement(val)
@@ -147,7 +148,7 @@ cdef class BlockPlacement:
147
148
slice s = self ._ensure_has_slice()
148
149
Py_ssize_t other_int, start, stop, step, l
149
150
150
- if isinstance (other, int ) and s is not None :
151
+ if PyInt_Check (other) and s is not None :
151
152
other_int = < Py_ssize_t> other
152
153
153
154
if other_int == 0 :
@@ -299,7 +300,7 @@ cdef slice_getitem(slice slc, ind):
299
300
300
301
s_start, s_stop, s_step, s_len = slice_get_indices_ex(slc)
301
302
302
- if isinstance (ind, slice ):
303
+ if PySlice_Check (ind):
303
304
ind_start, ind_stop, ind_step, ind_len = slice_get_indices_ex(ind,
304
305
s_len)
305
306
0 commit comments