Skip to content

Commit a73fa55

Browse files
committed
Use kind to speed up dtype decision
1 parent f19c6ed commit a73fa55

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

pandas/core/indexes/base.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@
106106
is_scalar,
107107
is_signed_integer_dtype,
108108
is_string_dtype,
109-
is_unsigned_integer_dtype,
110109
needs_i8_conversion,
111110
pandas_dtype,
112111
validate_all_hashable,
@@ -591,20 +590,20 @@ def _dtype_to_subclass(cls, dtype: DtypeObj):
591590

592591
return TimedeltaIndex
593592

594-
elif is_float_dtype(dtype):
593+
elif dtype.kind == "f":
595594
from pandas.core.api import Float64Index
596595

597596
return Float64Index
598-
elif is_unsigned_integer_dtype(dtype):
597+
elif dtype.kind == "u":
599598
from pandas.core.api import UInt64Index
600599

601600
return UInt64Index
602-
elif is_signed_integer_dtype(dtype):
601+
elif dtype.kind == "i":
603602
from pandas.core.api import Int64Index
604603

605604
return Int64Index
606605

607-
elif dtype == _dtype_obj:
606+
elif dtype.kind == "O":
608607
# NB: assuming away MultiIndex
609608
return Index
610609

0 commit comments

Comments
 (0)