File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -564,8 +564,7 @@ def is_excluded_dtype(dtype) -> bool:
564564 """
565565 These have kind = "O" but aren't string dtypes so need to be explicitly excluded
566566 """
567- is_excluded_checks = (is_period_dtype , is_interval_dtype , is_categorical_dtype )
568- return any (is_excluded (dtype ) for is_excluded in is_excluded_checks )
567+ return isinstance (dtype , (PeriodDtype , IntervalDtype , CategoricalDtype ))
569568
570569 return _is_dtype (arr_or_dtype , condition )
571570
@@ -1177,11 +1176,14 @@ def needs_i8_conversion(arr_or_dtype) -> bool:
11771176 # fastpath
11781177 dtype = arr_or_dtype
11791178 return dtype .kind in ["m" , "M" ] or dtype .type is Period
1180- return (
1181- is_datetime_or_timedelta_dtype (arr_or_dtype )
1182- or is_datetime64tz_dtype (arr_or_dtype )
1183- or is_period_dtype (arr_or_dtype )
1184- )
1179+
1180+ try :
1181+ dtype = get_dtype (arr_or_dtype )
1182+ except (TypeError , ValueError ):
1183+ return False
1184+ if isinstance (dtype , np .dtype ):
1185+ return dtype .kind in ["m" , "M" ]
1186+ return isinstance (dtype , (PeriodDtype , DatetimeTZDtype ))
11851187
11861188
11871189def is_numeric_dtype (arr_or_dtype ) -> bool :
Original file line number Diff line number Diff line change @@ -439,7 +439,9 @@ def array_equivalent(
439439 # Slow path when we allow comparing different dtypes.
440440 # Object arrays can contain None, NaN and NaT.
441441 # string dtypes must be come to this path for NumPy 1.7.1 compat
442- if is_string_dtype (left .dtype ) or is_string_dtype (right .dtype ):
442+ if left .dtype .kind in "OSU" or right .dtype .kind in "OSU" :
443+ # Note: `in "OSU"` is non-trivially faster than `in ["O", "S", "U"]`
444+ # or `in ("O", "S", "U")`
443445 return _array_equivalent_object (left , right , strict_nan )
444446
445447 # NaNs can occur in float and complex arrays.
You can’t perform that action at this time.
0 commit comments