pitrou commented on a change in pull request #8457:
URL: https://github.com/apache/arrow/pull/8457#discussion_r505566689



##########
File path: python/pyarrow/compute.py
##########
@@ -130,32 +146,38 @@ def _handle_options(name, option_class, options, kwargs):
     return options
 
 
-def _simple_unary_function(name):
-    func = get_function(name)
-    option_class = _option_classes.get(name)
-
-    if option_class is not None:
-        def wrapper(arg, *, options=None, memory_pool=None, **kwargs):
-            options = _handle_options(name, option_class, options, kwargs)
-            return func.call([arg], options, memory_pool)
-    else:
-        def wrapper(arg, *, memory_pool=None):
-            return func.call([arg], None, memory_pool)
-
-    return _decorate_compute_function(wrapper, name, func, option_class)
-
-
-def _simple_binary_function(name):
-    func = get_function(name)
-    option_class = _option_classes.get(name)
-
+_wrapper_template = dedent("""\
+    def make_wrapper(func, option_class):
+        def {func_name}({args_sig}, *, memory_pool=None):
+            return func.call([{args_sig}], None, memory_pool)
+        return {func_name}
+    """)
+
+_wrapper_options_template = dedent("""\
+    def make_wrapper(func, option_class):
+        def {func_name}({args_sig}, *, options=None, memory_pool=None,
+                        **kwargs):
+            options = _handle_options({func_name!r}, option_class, options,
+                                      kwargs)
+            return func.call([{args_sig}], options, memory_pool)
+        return {func_name}
+    """)

Review comment:
       We can use `__signature__`, which should work for documentation but some 
error messages will be less nice when the wrong number of arguments is given 
(because the interpreter doesn't inspect `__signature__` when functions are 
called).




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