Skip to content

Commit 0ae9b4d

Browse files
authored
PERF: Index[StringArray] (#46349)
1 parent 93da45a commit 0ae9b4d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pandas/core/arrays/string_.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
ExtensionArray,
4343
FloatingArray,
4444
IntegerArray,
45-
PandasArray,
4645
)
4746
from pandas.core.arrays.floating import FloatingDtype
4847
from pandas.core.arrays.integer import IntegerDtype
48+
from pandas.core.arrays.numpy_ import PandasArray
4949
from pandas.core.construction import extract_array
5050
from pandas.core.indexers import check_array_indexer
5151
from pandas.core.missing import isna

pandas/core/indexes/base.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
validate_tz_from_dtype,
149149
)
150150
from pandas.core.arrays.sparse import SparseDtype
151+
from pandas.core.arrays.string_ import StringArray
151152
from pandas.core.base import (
152153
IndexOpsMixin,
153154
PandasObject,
@@ -5033,7 +5034,11 @@ def _get_engine_target(self) -> ArrayLike:
50335034
Get the ndarray or ExtensionArray that we can pass to the IndexEngine
50345035
constructor.
50355036
"""
5036-
return self._values
5037+
vals = self._values
5038+
if isinstance(vals, StringArray):
5039+
# GH#45652 much more performant than ExtensionEngine
5040+
return vals._ndarray
5041+
return vals
50375042

50385043
def _from_join_target(self, result: np.ndarray) -> ArrayLike:
50395044
"""

0 commit comments

Comments
 (0)