Skip to content

Commit 0474de0

Browse files
duburcqastefanseefeld
authored andcommitted
Support numpy 2.0.0b1
1 parent 6c3f3ec commit 0474de0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/numpy/dtype.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,13 @@ python::detail::new_reference dtype::convert(object const & arg, bool align)
9898
return python::detail::new_reference(reinterpret_cast<PyObject*>(obj));
9999
}
100100

101-
int dtype::get_itemsize() const { return reinterpret_cast<PyArray_Descr*>(ptr())->elsize;}
101+
int dtype::get_itemsize() const {
102+
#if NPY_ABI_VERSION < 0x02000000
103+
return reinterpret_cast<PyArray_Descr*>(ptr())->elsize;
104+
#else
105+
return PyDataType_ELSIZE(reinterpret_cast<PyArray_Descr*>(ptr()));
106+
#endif
107+
}
102108

103109
bool equivalent(dtype const & a, dtype const & b) {
104110
// On Windows x64, the behaviour described on

0 commit comments

Comments
 (0)