I'm not willing to change the structured array behavior. This is something
I never used and don't know well. It would be easy for me to make mistake
without learning more about them. Also, logically, this is something else
and should be in another PR.

I fixed the comment style, simplified the if and moved the computation
inside the if (after validating this is equivalent).

About the if with NPY_OBJECT, why PyArray_GenericBinaryFunction will always
work when this is false? I think we need to keep it. Removing it would at
worst, generate bad results. Keeping it at worst would make it as slow as
before. Don't forget, numpy is missing many tests and I don't have the time
to look into this case in more details. So I think we should keep it.





On Thu, May 16, 2013 at 4:03 PM, seberg <notifications@github.com> wrote:

> In numpy/core/src/multiarray/arrayobject.c:
>
> > @@ -1280,6 +1280,18 @@ static void _unistripw(npy_ucs4 *s, int n)
> >              Py_INCREF(Py_False);
> >              return Py_False;
> >          }
> > +        result = PyArray_GenericBinaryFunction(self,
> > +                (PyObject *)other,
> > +                n_ops.equal);
> > +        if (result && result != Py_NotImplemented)
> > +          break;
> > +
> > +        /*
> > +         * I have been told that the rest of this case is probably an
> > +         * hack to support a few cases of structured arrays since
> > +         * ufuncs cannot handle general structured arrays.
> > +         */
> > +
> >          /* Make sure 'other' is an array */
> >          if (PyArray_TYPE(self) == NPY_OBJECT) {
>
> Seems I lost my comment. If we break out earlier, the check is unnecessary
> (it cannot be npy_object). However the block is there to force object
> dtype. I wonder if it would not be correct to force the dtype for void
> arrays. That way the code:
>
> a = np.array([(0,1)], dtype='i,i')
> a == (0, 1)
>
> should work. Would that be another fix, or is there anything that might go
> bad? Would need to test if array priority works correctly for that case
> then.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/numpy/numpy/pull/3324/files#r4263883>
> .
>