Skip to content

Commit 3792cde

Browse files
committed
simplify is_hashable
1 parent 7dd4fc1 commit 3792cde

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

pandas/core/dtypes/inference.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -356,19 +356,7 @@ def is_hashable(obj) -> TypeGuard[Hashable]:
356356
>>> is_hashable(a)
357357
False
358358
"""
359-
# Unfortunately, we can't use isinstance(obj, collections.abc.Hashable),
360-
# which can be faster than calling hash. That is because numpy scalars
361-
# fail this test.
362-
363-
# Reconsider this decision once this numpy bug is fixed:
364-
# https://github.com/numpy/numpy/issues/5562
365-
366-
try:
367-
hash(obj)
368-
except TypeError:
369-
return False
370-
else:
371-
return True
359+
return isinstance(obj, abc.Hashable)
372360

373361

374362
def is_sequence(obj) -> bool:

0 commit comments

Comments
 (0)