[Numpy-discussion] Non-numerical info associated with sub-arrays

Francesc Alted falted at openlc.org
Sat Dec 28 17:00:02 EST 2002

Mensaje citado por: Perry Greenfield <perry at stsci.edu>:

> Are you asking for an option to create record arrays with
> aligned fields (in the sense that the addresses of all values
> are consistent with their type)?

Yes, I'm advocating for that

> Or are you arguing that
> non-aligned columns must be prohibited? The former is certainly
> possible (not not very difficult to implement; basically it requires
> that record sizes must be a multiple of the largest numerical type,
> and that padding is placed within records to ensure that all fields
> have offsets that are a multiple of their size).

Well, for the sake of keeping the size of dataset to a minimum, I think it's 
not necessary to adjust all the record field sizes to the largest data type 
because depending on the type of the field, the padding can be shorter or 

For example, short ints only needs to be aligned in two-byte basis, while 
doubles need 4 bytes (or 8, I don't remember well). In any case, this depends 
on the architecture. But it is still possible to figure out safely what is the 
required minimum alignments for the different types. Look at Python's struct 
module for a good example on how you can reduce the padding to a minimum, 
without sacrificing performance.

Francesc Alted

More information about the NumPy-Discussion mailing list