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 11:06:56 UTC

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

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



##########
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:
       > 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 exactly the case here: the function definition mostly forwards `*args` and `**kwargs` to the function kernel and the function options constructor, respectively. See the `wrapper` definitions above.




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