[Numpy-discussion] ticket #1619

Charles R Harris charlesr.harris at gmail.com
Wed Mar 2 22:53:14 EST 2011

I think that this ticket can benefit from some discussion on the list. The
problem is as follows.

In [2]: np.dtype('i1, i4, i1', align=True)
Out[2]: dtype([('f0', '|i1'), ('', '|V3'), ('f1', '<i4'), ('f2', '|i1')])

In [3]: dtype([('f0', '|i1'), ('', '|V3'), ('f1', '<i4'), ('f2', '|i1')])
ValueError                                Traceback (most recent call last)

/home/charris/<ipython console> in <module>()

ValueError: two fields with the same name

Note that the second field in the dtype is inserted for alignment purposes
and isn't named. However, the list in the dtype can not be used to define a
dtype because the empty name is replaced by 'f1', which conflicts with the
following field.  The patch attached to the ticket has a rather complicated
work around for this that I would rather avoid. I would prefer some sort of
reserved name for alignment fields, maybe something like '*0', '*1', etc.
Another question I have is if alignment is supposed to be preserved across
architectures, that is, should it be possible to pickle/savez on one
architecture and read things in on another and still have the elements
aligned. I suspect this isn't worth doing, but one way or the other should
be decided.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110302/524dbf80/attachment.html>

More information about the NumPy-Discussion mailing list