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:43:26 UTC

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

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



##########
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 other benefit here is to confine the scope of `eval()`: now instead of using it to create the whole wrapper function we're only using it to get the signature right




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