Prevent potential data loss in numpy's dtype::get_itemsize(). by JohannesWilde · Pull Request #463 · boostorg/python · GitHub
Skip to content

Prevent potential data loss in numpy's dtype::get_itemsize().#463

Open
JohannesWilde wants to merge 7 commits into
boostorg:developfrom
JohannesWilde:NumpyDtypeElementSizeType
Open

Prevent potential data loss in numpy's dtype::get_itemsize().#463
JohannesWilde wants to merge 7 commits into
boostorg:developfrom
JohannesWilde:NumpyDtypeElementSizeType

Conversation

@JohannesWilde

Copy link
Copy Markdown

The numpy 2.0 migration guide states [https://numpy.org/devdocs/numpy_2_0_migration_guide.html]:

"PyDataType_ELSIZE and PyDataType_SET_ELSIZE (note that the result is now npy_intp and not int)."

Even though it is rather unlikely to have have elements larger than 2GB each, prevent potential numerical overflows, which could occur when casting ssize_t to int on 64-bit systems.

The numpy 2.0 migration guide states [https://numpy.org/devdocs/numpy_2_0_migration_guide.html]:

"PyDataType_ELSIZE and PyDataType_SET_ELSIZE (note that the result is now npy_intp and not int)."

Even though it is rather unlikely to have have elements larger than 2GB each, prevent potential numerical overflows, which could occur when casting ssize_t to int on 64-bit systems.
@JohannesWilde JohannesWilde changed the title Prevent potential data loss in numpy's dtype::get_itemsize(). WIP: Prevent potential data loss in numpy's dtype::get_itemsize(). Dec 14, 2024
@JohannesWilde JohannesWilde changed the title WIP: Prevent potential data loss in numpy's dtype::get_itemsize(). Prevent potential data loss in numpy's dtype::get_itemsize(). Dec 14, 2024
@JohannesWilde

JohannesWilde commented Dec 14, 2024

Copy link
Copy Markdown
Author

@JohannesWilde

Copy link
Copy Markdown
Author

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.

1 participant