[Numpy-discussion] GSOC 2013

Eric Firing efiring at hawaii.edu
Tue Mar 5 02:45:20 EST 2013

On 2013/03/04 9:01 PM, Nicolas Rougier wrote:
>> >This made me think of a serious performance limitation of structured dtypes: a
>> >structured dtype is always "packed", which may lead to terrible byte alignment
>> >for common types.  For instance, `dtype([('a', 'u1'), ('b',
>> >'u8')]).itemsize == 9`,
>> >meaning that the 8-byte integer is not aligned as an equivalent C-struct's
>> >would be, leading to all sorts of horrors at the cache and register level.

Doesn't the "align" kwarg of np.dtype do what you want?

In [2]: dt = np.dtype(dict(names=['a', 'b'], formats=['u1', 'u8']), 

In [3]: dt.itemsize
Out[3]: 16


More information about the NumPy-Discussion mailing list