Skip to content

Commit 095998c

Browse files
authored
PERF: Using Numpy C-API when calling np.arange (#32804)
Co-authored-by: MomIsBestFriend <>
1 parent 19624de commit 095998c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pandas/_libs/internals.pyx

+4-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,10 @@ cdef slice_getitem(slice slc, ind):
308308
return slice(s_start, s_stop, s_step)
309309

310310
else:
311-
return np.arange(s_start, s_stop, s_step, dtype=np.int64)[ind]
311+
# NOTE:
312+
# this is the C-optimized equivalent of
313+
# `np.arange(s_start, s_stop, s_step, dtype=np.int64)[ind]`
314+
return cnp.PyArray_Arange(s_start, s_stop, s_step, NPY_INT64)[ind]
312315

313316

314317
@cython.boundscheck(False)

0 commit comments

Comments
 (0)