Skip to content

ENH: Add new C-API for parsing user defined dtypes - #33540

Open
riku-sakamoto wants to merge 2 commits into
numpy:mainfrom
riku-sakamoto:add/api_to_parse_user_dtype_string
Open

riku-sakamoto wants to merge 2 commits into
numpy:mainfrom
riku-sakamoto:add/api_to_parse_user_dtype_string

Conversation

@riku-sakamoto

@riku-sakamoto riku-sakamoto commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

PR summary

Closes #30699

Two new C-API functions are added to parse user defined dtypes.

  • PyArrayDTypeMeta_RecognizeDescr: This function take a Python string and returns 1 if the string is a valid user defined dtype, otherwise returns 0.
  • PyArrayDTypeMeta_StringParser: This function takes a Python string and returns a new reference to the corresponding user defined dtype object if the string is valid, otherwise returns NULL.

AI Disclosure

I used Codex to understand the existing codebase and review my changes quickly.
I wrote all changes and tests manually, and I take full responsibility for the correctness of this PR.

Two new C-API functions are added to parse user defined dtypes.
* `PyArrayDTypeMeta_RecognizeDescr`: This function take a Python string and returns 1
if the string is a valid user defined dtype, otherwise returns 0.
* `PyArrayDTypeMeta_StringParser`: This function takes a Python string and returns a new reference
to the corresponding user defined dtype object if the string is valid, otherwise returns NULL and sets an error.
@charris charris added this to the 2.7.0 Release milestone Dec 1, 2026
@riku-sakamoto

Copy link
Copy Markdown
Contributor Author

The clang_ASAN failure seems unrelated to this PR. GitHub Actions reports that the runner lost communication with the server.

@ikrommyd

ikrommyd commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

I hit rerun but it looks like it's hanging again? We are not hitting this one main so if it's reproducible it might be a problem with the PR.

Edit: nvm it passed now. Ping if you see it again.

This branch has not been deployed

No deployments
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.

ENH: add a hook to the DType API for parsing dtype strings

3 participants