Skip to content

Commit

Permalink
PERF: Index[StringArray] (pandas-dev#46349)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored and yehoshuadimarsky committed Jul 13, 2022
1 parent 7d5de28 commit 171285a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pandas/core/arrays/string_.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
ExtensionArray,
FloatingArray,
IntegerArray,
PandasArray,
)
from pandas.core.arrays.floating import FloatingDtype
from pandas.core.arrays.integer import IntegerDtype
from pandas.core.arrays.numpy_ import PandasArray
from pandas.core.construction import extract_array
from pandas.core.indexers import check_array_indexer
from pandas.core.missing import isna
Expand Down
7 changes: 6 additions & 1 deletion pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
validate_tz_from_dtype,
)
from pandas.core.arrays.sparse import SparseDtype
from pandas.core.arrays.string_ import StringArray
from pandas.core.base import (
IndexOpsMixin,
PandasObject,
Expand Down Expand Up @@ -5033,7 +5034,11 @@ def _get_engine_target(self) -> ArrayLike:
Get the ndarray or ExtensionArray that we can pass to the IndexEngine
constructor.
"""
return self._values
vals = self._values
if isinstance(vals, StringArray):
# GH#45652 much more performant than ExtensionEngine
return vals._ndarray
return vals

def _from_join_target(self, result: np.ndarray) -> ArrayLike:
"""
Expand Down

0 comments on commit 171285a

Please sign in to comment.