[Numpy-discussion] Struct alignment

Dag Sverre Seljebotn dagss@student.matnat.uio...
Sat Apr 18 08:36:36 CDT 2009

I'm looking at fixing up support for NumPy record arrays in Cython, and 
realize my knowledge of NumPy is a bit too limited. Searching the docs 
didn't enlighten me, so:

Does NumPy always use packed alignment for nested dtypes?

In [35]: T
Out[35]: dtype([('f0', '<f4'), ('f1', '|i1'), ('f2', '<i4')])

In [36]: T.itemsize
Out[36]: 9

In [37]: T.alignment
Out[37]: 1

In [48]: np.zeros(3,T).itemsize
Out[48]: 9

Is there a way of making an array with the above dtype but 12 bytes per 
element? Or can you guarantee that NumPy arrays with records are always 

Dag Sverre

More information about the Numpy-discussion mailing list