[Numpy-discussion] Structured array copying by field name (was: Numpy 1.6 schedule)

Mark Wiebe mwwiebe at gmail.com
Fri Mar 11 15:20:01 EST 2011


On Fri, Mar 11, 2011 at 1:07 AM, Ralf Gommers
<ralf.gommers at googlemail.com>wrote:

> On Tue, Mar 8, 2011 at 1:35 AM, Pauli Virtanen <pav at iki.fi> wrote:
> >
> > Structured array copying copies by field name.
> >
> > Commit 22d96096bf7d5fb199ca80f2fcd04e8d27815476
> >
> > Before:
> >
> >>>> x = np.array([(0, 1)], dtype=[('a', int), ('b', int)])
> >>>> y = np.array([(2, 3)], dtype=[('a', int), ('b', int)])
> >>>> y = np.array([(2, 3)], dtype=[('b', int), ('a', int)])
> >>>> x[:] = y
> >>>> x
> > array([(2, 3)],
> >      dtype=[('a', '<i4'), ('b', '<i4')])
> >
> > After:
> >
> >>>> x = np.array([(0, 1)], dtype=[('a', int), ('b', int)])
> >>>> y = np.array([(2, 3)], dtype=[('b', int), ('a', int)])
> >>>> x[:] = y
> >>>> x
> > array([(3, 2)],
> >      dtype=[('a', '<i4'), ('b', '<i4')])
> >
> > This seems like a pretty hazardous change. Granted, it's in
> > a bit of a grey area, but people may rely on this.
>
> This is still backwards incompatible in current master. Should it be
> changed back for 1.6?
>

I strongly dislike the behavior in 1.5 and earlier, for reasons such as the
example given here:

http://mail.scipy.org/pipermail/numpy-discussion/2011-March/055214.html

<http://mail.scipy.org/pipermail/numpy-discussion/2011-March/055214.html>No
problems so far have been traced back to this change, indicating that this
type of assignment was previously utilized very little, so I'm strongly in
favor of keeping it in. Based on my knowledge of the code, I'm pretty sure
it's a significant performance improvement as well.

-Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110311/fe3b1191/attachment.html>


More information about the NumPy-Discussion mailing list