You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/05/28 15:07:13 UTC

[GitHub] [arrow] jorisvandenbossche commented on a change in pull request #7273: ARROW-5854: [Python] Expose compare kernels on Array class

jorisvandenbossche commented on a change in pull request #7273:
URL: https://github.com/apache/arrow/pull/7273#discussion_r431910468



##########
File path: python/pyarrow/array.pxi
##########
@@ -602,14 +604,28 @@ cdef class Array(_PandasConvertible):
         self.ap = sp_array.get()
         self.type = pyarrow_wrap_data_type(self.sp_array.get().type())
 
-    def __eq__(self, other):
-        raise NotImplementedError('Comparisons with pyarrow.Array are not '
-                                  'implemented')
-
     def _debug_print(self):
         with nogil:
             check_status(DebugPrint(deref(self.ap), 0))
 
+    def __richcmp__(self, other, int op):
+        cdef str function_name
+
+        if op == Py_EQ:
+            function_name = "equal"
+        elif op == Py_NE:
+            function_name = "not_equal"
+        elif op == Py_GT:
+            function_name = "greater"
+        elif op == Py_GE:
+            function_name = "greater_equal"
+        elif op == Py_LT:
+            function_name = "less"
+        elif op == Py_LE:
+            function_name = "less_equal"
+
+        return _pc().call_function(function_name, [self, other])

Review comment:
       Moved the `op` to function name conversion into a helper function




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org