Skip to content

Conversation

@jbrockmendel
Copy link
Member

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.

Copy link
Contributor

@jreback jreback left a 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)

return False


def np_can_hold_element(dtype: np.dtype, element: Any):
Copy link
Contributor

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

@jreback jreback added Dtype Conversions Unexpected or buggy dtype conversions Refactor Internal refactoring of code labels Jan 3, 2022
@jbrockmendel
Copy link
Member Author

would it be better to use None as the return value rathe than using exceptions as control flow ? (e.g. performance)

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.

@jreback
Copy link
Contributor

jreback commented Jan 3, 2022

There are some performance concerns i have with this function, but try/except overhead is not among them.

oh ok.

@jreback jreback added this to the 1.4 milestone Jan 3, 2022
@jreback jreback merged commit 30297db into pandas-dev:master Jan 4, 2022
@jbrockmendel jbrockmendel deleted the ref-can_hold-validate_fill branch January 4, 2022 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Dtype Conversions Unexpected or buggy dtype conversions Refactor Internal refactoring of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants