summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorFrederic <nouiz@nouiz.org>2013-05-16 14:49:43 -0400
committerFrederic <nouiz@nouiz.org>2013-05-16 14:49:43 -0400
commit90ea64b027a4868c47f169b4dd88c239e720bc25 (patch)
tree70d0bef1aa54e7d7a8c3eca853805994c01168ed /numpy
parent1d3fa042225ac18f505bd2e37b47b3ed0af3a67a (diff)
downloadnumpy-90ea64b027a4868c47f169b4dd88c239e720bc25.tar.gz
reorder code to remove not needed computation in some cases.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/arrayobject.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/numpy/core/src/multiarray/arrayobject.c b/numpy/core/src/multiarray/arrayobject.c
index a380a4806..60ea87954 100644
--- a/numpy/core/src/multiarray/arrayobject.c
+++ b/numpy/core/src/multiarray/arrayobject.c
@@ -1280,6 +1280,16 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
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) {
dtype = PyArray_DTYPE(self);
@@ -1297,9 +1307,6 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
return Py_NotImplemented;
}
- result = PyArray_GenericBinaryFunction(self,
- (PyObject *)other,
- n_ops.equal);
if ((result == Py_NotImplemented) &&
(PyArray_TYPE(self) == NPY_VOID)) {
int _res;
@@ -1337,6 +1344,15 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
Py_INCREF(Py_True);
return Py_True;
}
+ result = PyArray_GenericBinaryFunction(self, (PyObject *)other,
+ n_ops.not_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) {
dtype = PyArray_DTYPE(self);
@@ -1354,8 +1370,6 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
return Py_NotImplemented;
}
- result = PyArray_GenericBinaryFunction(self, (PyObject *)other,
- n_ops.not_equal);
if ((result == Py_NotImplemented) &&
(PyArray_TYPE(self) == NPY_VOID)) {
int _res;