pitrou commented on a change in pull request #8457:
URL: https://github.com/apache/arrow/pull/8457#discussion_r505690052
##########
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}
+ """)
+
+
+def _wrap_function(name, func):
+ option_class = _get_options_class(func)
+ arg_names = _get_arg_names(func)
+ args_sig = ', '.join(arg_names)
+
Review comment:
ARROW-10316
----------------------------------------------------------------
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]