wesm commented on pull request #7240:
URL: https://github.com/apache/arrow/pull/7240#issuecomment-632944653


   @xhochy @pitrou @kszucs @jorisvandenbossche  I just added Python bindings 
for this new functionality including generic argument packing and function 
dispatching. The new implementation of `pyarrow.compute.sum` for example is now
   
   ```
   def sum(array):
       """
       Sum the values in a numerical (chunked) array.
   
       Parameters
       ----------
       array : pyarrow.Array or pyarrow.ChunkedArray
   
       Returns
       -------
       sum : pyarrow.Scalar
       """
       return call_function('sum', [array])
   ```
   
   So we're going to be able to go around the Python codebase and delete a 
_ton_ of code. 
   
   I haven't written unit tests for this part (let's do this later), but I 
added wrappers for the registry, functions, and kernels:
   
   ```
   In [1]: import pyarrow.compute as pc                                         
                             
   
   In [2]: reg = pc.function_registry()                                         
                             
   
   In [3]: reg.list_functions()                                                 
                             
   Out[3]: 
   ['add',
    'and',
    'and_kleene',
    'count',
    'dict_encode',
    'equals',
    'filter',
    'greater',
    'greater_equal',
    'invert',
    'isin',
    'less',
    'less_equal',
    'match',
    'mean',
    'minmax',
    'not_equals',
    'or',
    'or_kleene',
    'partition_indices',
    'sort_indices',
    'sum',
    'take',
    'unique',
    'value_counts',
    'xor']
   
   In [4]: reg.get_function('equals')                                           
                             
   Out[4]: 
   arrow.compute.Function
   kind: scalar
   num_kernels: 21
   
   In [5]: reg.get_function('equals').list_kernels()                            
                             
   Out[5]: 
   [ScalarKernel<(any[bool], any[bool]) -> bool>,
    ScalarKernel<(any[uint8], any[uint8]) -> bool>,
    ScalarKernel<(any[uint16], any[uint16]) -> bool>,
    ScalarKernel<(any[uint32], any[uint32]) -> bool>,
    ScalarKernel<(any[uint64], any[uint64]) -> bool>,
    ScalarKernel<(any[int8], any[int8]) -> bool>,
    ScalarKernel<(any[int16], any[int16]) -> bool>,
    ScalarKernel<(any[int32], any[int32]) -> bool>,
    ScalarKernel<(any[int64], any[int64]) -> bool>,
    ScalarKernel<(any[float], any[float]) -> bool>,
    ScalarKernel<(any[double], any[double]) -> bool>,
    ScalarKernel<(any[binary], any[binary]) -> bool>,
    ScalarKernel<(any[string], any[string]) -> bool>,
    ScalarKernel<(any[large_binary], any[large_binary]) -> bool>,
    ScalarKernel<(any[large_string], any[large_string]) -> bool>,
    ScalarKernel<(any[date32[day]], any[date32[day]]) -> bool>,
    ScalarKernel<(any[date64[ms]], any[date64[ms]]) -> bool>,
    ScalarKernel<(any[timestamp(s)], any[timestamp(s)]) -> bool>,
    ScalarKernel<(any[timestamp(ms)], any[timestamp(ms)]) -> bool>,
    ScalarKernel<(any[timestamp(us)], any[timestamp(us)]) -> bool>,
    ScalarKernel<(any[timestamp(ns)], any[timestamp(ns)]) -> bool>]
   ```
   
   Needless to say very excited about all of this. 


----------------------------------------------------------------
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:
[email protected]


Reply via email to