amol- commented on code in PR #41904:
URL: https://github.com/apache/arrow/pull/41904#discussion_r1695584697


##########
python/pyarrow/_compute.pyx:
##########
@@ -473,7 +476,7 @@ cdef class MetaFunction(Function):
 
 cdef _pack_compute_args(object values, vector[CDatum]* out):
     for val in values:
-        if isinstance(val, (list, np.ndarray)):
+        if isinstance(val, list) or (np is not None and isinstance(val, 
np.ndarray)):

Review Comment:
   I suggest we make a `SUPPORTED_INPUT_LIST_TYPES` (happy with any better name 
if available) and change the `isinstance` checks to be `isinstance(val, 
SUPPORTED_INPUT_LIST_TYPES)` 
   
   then use
   ```
   SUPPORTED_INPUT_LIST_TYPES = (list, tuple)
   try:
     import numpy as np
   except ImportError:
     np = None
   else:
     SUPPORTED_INPUT_LIST_TYPES += (np.ndarray, )
   ```
   
   That would avoid the isinstance check in every single place and would make 
it more reasable the `if`s



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to