-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REF: separate numpy-specific part of can_hold_element #45166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REF: separate numpy-specific part of can_hold_element #45166
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be better to use None
as the return value rathe than using exceptions as control flow ? (e.g. performance)
pandas/core/dtypes/cast.py
Outdated
return False | ||
|
||
|
||
def np_can_hold_element(dtype: np.dtype, element: Any): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a return Any
That becomes ambiguous with if the actual element is None. There are some performance concerns i have with this function, but try/except overhead is not among them. |
oh ok. |
By returning the value instead of just a bool, we open the option to return the casted value, which is what we'll do in the follow-up, which will let us de-duplicate NumericIndex._validate_fill_value. By separating out the np-specific parts, we'll be able to improve perf in a couple of places.