Skip to content

MAINT: treat str special in _array_converter and use it in strings.py - #32297

Draft
mhvk wants to merge 1 commit into
numpy:mainfrom
mhvk:array_converter_special_case_str
Draft

MAINT: treat str special in _array_converter and use it in strings.py#32297
mhvk wants to merge 1 commit into
numpy:mainfrom
mhvk:array_converter_special_case_str

Conversation

@mhvk

@mhvk mhvk commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

This is a follow-up to #32040 (comment), where I suggested that once we start treating str properly as a scalar for StringDType, we might be able to do some of the handling of it using _array_converter. It needs a small change to _array_converter (hence ping @seberg), but with it the code in strings.py does become somewhat simpler (especially for the T case).

Note that in principle it would be nice to have np.result_type(array, "string") work, just as is the case for np.result_type(array, 1.0). However, strings are already greedily interpreted as dtypes, so that doesn't work (goes to show that "conveniences" are not always a good idea). But _array_converter does not have that problem.

Opening as draft for now, since I'm not 100% sure this is the best approach (esp. for _array_converter, but also just in ensuring consistency between different numpy parts).

No AI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant