[Numpy-discussion] Array data and struct alignment

Travis Oliphant oliphant.travis at ieee.org
Sat Apr 29 15:04:10 CDT 2006

Albert Strasheim wrote:
> Hello all
> I'm busy wrapping a C library with NumPy. Some of the functions operate on a
> buffer containing structs that look like this:
> struct node {
>   int index;
>   double value;
> };

In my previous discussion I was wrong.  You cannot use the 
array_descriptor format for a data-type and the align keyword at the 
same time.  You need to use a different method to specify fields.

This, for example:

descr = dtype({'names':['index', 'value'], 'formats':[intc,'f8']},align=1)

On my (32-bit) system it doesn't produce any difference from align=0.  


More information about the Numpy-discussion mailing list