Skip to content

Fix PyArray_DTypeMeta definition when Py_LIMITED_API is disabled#532

Merged
Icxolu merged 1 commit intoPyO3:mainfrom
mattiapenati:limited-api
Feb 17, 2026
Merged

Fix PyArray_DTypeMeta definition when Py_LIMITED_API is disabled#532
Icxolu merged 1 commit intoPyO3:mainfrom
mattiapenati:limited-api

Conversation

@mattiapenati
Copy link
Contributor

When Py_LIMITED_API is disabled, PyArray_DTypeMeta has a different memory layout than PyTypeObject. This is explicitly documented in the NumPy C-API reference, which states that PyArray_DTypeMeta contains additional fields beyond those in PyTypeObject.

This structure is confirmed by the header file definition.

Copy link
Member

@Icxolu Icxolu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, looks like this is a npyffi fix only and was not used within our abstraction layer itself as far as I can see.

I think we are still missing a field in the struct. Also could you please add a changelog entry for this fix.

Comment on lines 557 to 558
pub singleton: *mut PyArray_Descr,
pub scalar_type: *mut PyTypeObject,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the type_num field is missing here, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much! I completely missed that field.

@mattiapenati
Copy link
Contributor Author

I updated the changelog and wrote "unreleased" because I'm not sure what version number to use.

Copy link
Member

@Icxolu Icxolu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thank you very much!

@Icxolu Icxolu merged commit e5ed4a9 into PyO3:main Feb 17, 2026
76 checks passed
@mattiapenati mattiapenati deleted the limited-api branch February 19, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments