@@ -564,6 +564,8 @@ class dtype : public object {
564
564
m_ptr = from_args (args).release ().ptr ();
565
565
}
566
566
567
+ // / Return dtype for the given typenum (one of the NPY_TYPES).
568
+ // / https://numpy.org/devdocs/reference/c-api/array.html#c.PyArray_DescrFromType
567
569
explicit dtype (int typenum)
568
570
: object (detail::npy_api::get ().PyArray_DescrFromType_ (typenum), stolen_t {}) {
569
571
if (m_ptr == nullptr ) {
@@ -586,16 +588,6 @@ class dtype : public object {
586
588
return detail::npy_format_descriptor<typename std::remove_cv<T>::type>::dtype ();
587
589
}
588
590
589
- // / Return dtype for the given typenum (one of the NPY_TYPES).
590
- // / https://numpy.org/devdocs/reference/c-api/array.html#c.PyArray_DescrFromType
591
- static dtype from_typenum (int typenum) {
592
- auto *ptr = detail::npy_api::get ().PyArray_DescrFromType_ (typenum);
593
- if (!ptr) {
594
- throw error_already_set ();
595
- }
596
- return reinterpret_steal<dtype>(ptr);
597
- }
598
-
599
591
// / Size of the data type in bytes.
600
592
ssize_t itemsize () const { return detail::array_descriptor_proxy (m_ptr)->elsize ; }
601
593
@@ -1293,7 +1285,7 @@ struct npy_format_descriptor<
1293
1285
public:
1294
1286
static constexpr int value = values[detail::is_fmt_numeric<T>::index];
1295
1287
1296
- static pybind11::dtype dtype () { return pybind11::dtype::from_typenum ( value); }
1288
+ static pybind11::dtype dtype () { return pybind11::dtype ( /* typenum */ value); }
1297
1289
};
1298
1290
1299
1291
template <typename T>
@@ -1302,7 +1294,7 @@ struct npy_format_descriptor<T, enable_if_t<is_same_ignoring_cvref<T, PyObject *
1302
1294
1303
1295
static constexpr int value = npy_api::NPY_OBJECT_;
1304
1296
1305
- static pybind11::dtype dtype () { return pybind11::dtype::from_typenum ( value); }
1297
+ static pybind11::dtype dtype () { return pybind11::dtype ( /* typenum */ value); }
1306
1298
};
1307
1299
1308
1300
#define PYBIND11_DECL_CHAR_FMT \
0 commit comments