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 2021/07/01 10:02:10 UTC

[GitHub] [arrow] amol- commented on a change in pull request #10581: ARROW-10316: [Python] Improve introspection of compute function options

amol- commented on a change in pull request #10581:
URL: https://github.com/apache/arrow/pull/10581#discussion_r662143862



##########
File path: python/pyarrow/compute.py
##########
@@ -197,16 +215,13 @@ def _wrap_function(name, func):
     args_sig = ', '.join(arg_names)
     kwonly = '' if arg_names[-1].startswith('*') else ', *'
 
-    # Generate templated wrapper, so that the signature matches
-    # the documented argument names.
-    ns = {}
-    if option_class is not None:
-        template = _wrapper_options_template
-    else:
-        template = _wrapper_template
-    exec(template.format(func_name=name, args_sig=args_sig, kwonly=kwonly),
-         globals(), ns)
-    wrapper = ns['make_wrapper'](func, option_class)
+    # We make a generic wrapper with a simple argument-handling
+    # machinery, but we also add a __wrapped__ attribute pointing
+    # to a dummy callable with the desired signature for introspection
+    # and documentation.
+    wrapper = _make_generic_wrapper(name, func, option_class)
+    wrapper.__wrapped__ = _make_dummy_equivalent(args_sig, kwonly,
+                                                 option_class)

Review comment:
       While I do see how it can work, I'm not sure I got the benefit of building a dummy function with the right signature wrapped in the real function with the wrong signature.
   
   I mean, if you are building the function with the right signature in `make_dummy_equivalent`, while not make that one not dummy, have it invoke the real compute function and directly return it?
   
   The only reason I could think of is that in reality the signature you want to expose is not the real one you want to use.




-- 
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: github-unsubscribe@arrow.apache.org

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