[Numpy-discussion] Question about typenum

Valentin Haenel valentin at haenel.co
Tue Oct 8 15:36:01 EDT 2013


* Richard Hattersley <rhattersley at gmail.com> [2013-10-08]:
> 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.

Excellent! Thank you very much!

V-



More information about the NumPy-Discussion mailing list