In particular both include logic for working around Categoricals. Not sure how much is shareable, but worth a shot.

Comment From: yuri-stepanov

I will try to look at that. From the first glance not sure I can make it more readable, but I will give it shot. If anything will pan out I will create a PR. Otherwise I will comment here =)

Comment From: yuri-stepanov

take

Comment From: yuri-stepanov

Just wanted to update that I am still looking at that refactoring and if I am not blocking anyone I would be glad to continue. This took me on a fascinating adventure around pandas \ numpy type system =).

At the moment I was looking through the code and relevant issues discussion like #26778 and #37258. It was interesting to learn about all of this corner cases. I think that at the moment the best that can be done without breaking the compatibility is refactoring of the logic for categorical types, as was mentioned by @jbrockmendel, but I really need to think where is the best place to put it.

Comment From: jbrockmendel

but I really need to think where is the best place to put it

Newly-implemented dtypes.cast.find_result_type

Comment From: yuri-stepanov

@jbrockmendel I think you beat me to it. Still it was interesting =)

Comment From: jbrockmendel

Closing as pushed as far is it can go without API changes.