[Numpy-discussion] Question about typenum

Richard Hattersley rhattersley at gmail.com
Tue Oct 8 15:21:25 EDT 2013


On 8 October 2013 19:56, Valentin Haenel <valentin at haenel.co> wrote:

> 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?
>

In short: yes.

`PyArray_TypeObjectFromType` first uses `PyArray_DescrFromType` to figure
out the dtype from the type number, and then it returns the corresponding
array scalar type. Passing this array scalar type to `np.dtype` gets you
back to the dtype that had just been looked up inside TypeObjectFromType.

Regards,
Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20131008/98988814/attachment.html>


More information about the NumPy-Discussion mailing list