Hi Richard, * Richard Hattersley <[email protected]> [2013-10-08]: > On 8 October 2013 13:23, Valentin Haenel <[email protected]> wrote: > > > Certain functions, like > > `PyArray_SimpleNewFromData` `PyArray_SimpleNew` take a typeenum > > Is there any way to go from typeenum to something that can be > > passed to the dtype constructor, like mapping 12 -> '<f8'? > > > > If you just want the corresponding dtype instance (aka PyArray_Descr) then > `PyArray_DescrFromType` should be what you're after. > > But if you really need the '<f8' string then I'd be tempted to get the > PyArray_Descr and then use the Python API (e.g. PyObject_GetAttrString) to > request the "str" attribute. Under the hood this attribute is implemented > by `arraydescr_protocol_typestr_get` but that's not part of the public API.
Thanks for your answer. I ended up using: PyArray_TypeObjectFromType from cython so: np.dtype(cnp.PyArray_TypeObjectFromType(self.ndtype)).str Maybe i can avoid the np.dtype call, when using PyArray_Descr? best, V- _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
