File tree 3 files changed +7
-1
lines changed
3 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ Deprecations
101
101
102
102
Performance improvements
103
103
~~~~~~~~~~~~~~~~~~~~~~~~
104
- -
104
+ - Performance improvement in :meth: ` Index.take ` when `` indices `` is a full range indexer from zero to length of index ( :issue: ` 56806 `)
105
105
-
106
106
107
107
.. ---------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -1157,6 +1157,9 @@ def take(
1157
1157
indices = ensure_platform_int (indices )
1158
1158
allow_fill = self ._maybe_disallow_fill (allow_fill , fill_value , indices )
1159
1159
1160
+ if indices .ndim == 1 and lib .is_range_indexer (indices , len (self )):
1161
+ return self .copy ()
1162
+
1160
1163
# Note: we discard fill_value and use self._na_value, only relevant
1161
1164
# in the case where allow_fill is True and fill_value is not None
1162
1165
values = self ._values
Original file line number Diff line number Diff line change @@ -2247,6 +2247,9 @@ def take(
2247
2247
# only fill if we are passing a non-None fill_value
2248
2248
allow_fill = self ._maybe_disallow_fill (allow_fill , fill_value , indices )
2249
2249
2250
+ if indices .ndim == 1 and lib .is_range_indexer (indices , len (self )):
2251
+ return self .copy ()
2252
+
2250
2253
na_value = - 1
2251
2254
2252
2255
taken = [lab .take (indices ) for lab in self .codes ]
You can’t perform that action at this time.
0 commit comments