From 07e17551028fb7449e10ed9dbb5914c027ac8ac8 Mon Sep 17 00:00:00 2001 From: pbrochart Date: Mon, 14 Apr 2025 11:58:42 +0200 Subject: [PATCH] PERF: Restore old performances with .isin() on columns typed as np.uint64 --- pandas/core/algorithms.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py index e6847b380a7e8..2d457dd9004d1 100644 --- a/pandas/core/algorithms.py +++ b/pandas/core/algorithms.py @@ -511,10 +511,11 @@ def isin(comps: ListLike, values: ListLike) -> npt.NDArray[np.bool_]: len(values) > 0 and values.dtype.kind in "iufcb" and not is_signed_integer_dtype(comps) + and not isna(values).any() + and not np.isinf(values).any() ): - # GH#46485 Use object to avoid upcast to float64 later # TODO: Share with _find_common_type_compat - values = construct_1d_object_array_from_listlike(orig_values) + values = np.asarray(list(orig_values), dtype=np.unsignedinteger) elif isinstance(values, ABCMultiIndex): # Avoid raising in extract_array