Skip to content

Conversation

@jorisvandenbossche
Copy link
Member

This follows-up on the comments here #62105 (comment) (on the PR that introduced _cast_pointwise_result / removed _from_scalars)

This PR does a few things:

  • Ensure (backwards) compability for external EAs, by ensuring that the default implementation for _cast_pointwise_result still does the minimal effort to try to return an instance of itself (the current implementation never returned the EA itself).
    • Doing this I also made it call _from_scalars for back compat with external EAs that already implemented this logic by overriding that method. This might only be geopandas, so also fine with eventually deprecating that method (and then _cast_pointwise_result can directly call _from_sequence, i.e. what the default impl for _from_scalars does now)
  • Add a small cast_pointwise_result functional wrapper around EA._cast_pointwise_result. The reason for this is that I don't think the EA should be responsible to know all kinds of (optional) type inference of pandas, it should just take care of the type inference to its own types.
    • External EAs could also achieve that by ensuring they always do result = super()._cast_pointwise_result(values), and we can document that they should do that (and then we can update the base class implementation whenever type inference defaults/options change). My feeling is that it is cleaner to not require that (i.e. let the EA handle just what it knows about, which is less error prone) and have that general logic outside of the EA, but I can also roll that back.
  • Expanded the docstring for _cast_pointwise_result for EA authors to clarify what this method should do (but this might need to be updated depending on the above)

cc @jbrockmendel

@jorisvandenbossche jorisvandenbossche added this to the 3.0 milestone Dec 15, 2025
@jorisvandenbossche jorisvandenbossche added the ExtensionArray Extending pandas with custom dtypes or arrays. label Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ExtensionArray Extending pandas with custom dtypes or arrays.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant