[Numpy-discussion] __array_typestr__

Francesc Altet faltet at carabos.com
Fri Apr 1 02:17:36 EST 2005

A Divendres 01 Abril 2005 11:31, Travis Oliphant va escriure:
> * I'm wondering about including multiple types in the typestr.  On the
> one hand we could describe complicated structures by packing all the
> information into the  typestr.  On the other hand, it may be better if
> we just use 'V8' to describe an 8-byte memory buffer with  an additional
> attribute that contains both the names and the typestr:
> __array_recinfo__ = (('real','f4'),('imag','f4'))
> or  for a "rational type"
> __array_recinfo__ = (('numer','i4'),('denom','i4'))
> so that the detail of the typecode for a "record" type is handled by
> another special method using tuples.    On this level, we could add the
> possibility of specifying a shape for a small array inside (just like
> the record array of numarray does).


__array_recinfo__ = (('numer','i4', (3,4)),('denom','i4', (2,))) ?

Also, this can be easily extended to nested types:

__array_recinfo__ = (('a','i4',(3,4)),(('b','i4',(2,)),('c','f4',(10,2)))

Well, this looks pretty good to me. It has nothing to do with struct
format, but is much more usable, of course.


>qo<   Francesc Altet     http://www.carabos.com/
V  V   Cárabos Coop. V.   Enjoy Data

More information about the NumPy-Discussion mailing list