From 02adbd82b77ccb0a64539691a24d031497c0d91b Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Wed, 18 Mar 2020 14:46:17 +0200 Subject: [PATCH] PERF: Using Numpy C-API when calling `np.arange` --- pandas/_libs/internals.pyx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/_libs/internals.pyx b/pandas/_libs/internals.pyx index 5545302fcbfc4..63f076b7ee993 100644 --- a/pandas/_libs/internals.pyx +++ b/pandas/_libs/internals.pyx @@ -308,7 +308,10 @@ cdef slice_getitem(slice slc, ind): return slice(s_start, s_stop, s_step) else: - return np.arange(s_start, s_stop, s_step, dtype=np.int64)[ind] + # NOTE: + # this is the C-optimized equivalent of + # `np.arange(s_start, s_stop, s_step, dtype=np.int64)[ind]` + return cnp.PyArray_Arange(s_start, s_stop, s_step, NPY_INT64)[ind] @cython.boundscheck(False)