Repository navigation
[Python][RDF] Enable pure Python callbacks in RDataFrame - #23658
Merged
Merged
Conversation
Test Results 24 files 24 suites 4d 0h 58m 24s ⏱️ For more details on these failures, see this check. Results for commit 4035219. ♻️ This comment has been updated with latest results. |
Contributor
Author
|
Doesn't work out of the box because of compiler-research/cppjit#151 To land the functionality while that feature gets fixed, we will opt for explicit instanciation of Define by building the callback's function pointer signature using its annotations |
A Python callable that is not decorated with `ROOT.Numba.Declare` is now passed to `Define` and `Filter` as it is and runs in the Python interpreter, instead of being implicitly JIT compiled with Numba. Its type annotations give the function pointer type used to explicitly instantiate `Define` and `Filter`. Assisted-by: Claude Opus 5.5
…ables Assisted-by: Claude Opus 5.5
…are twice `FunctionJitter` declared again the callables already declared with `ROOT.Numba.Declare`, which failed with a redefinition error, so passing a decorated callable with `extra_args` to `Define` or `Filter` did not work. Assisted-by: Claude Opus 5.5
Assisted-by: Claude Opus 5.5
siliataider
marked this pull request as ready for review
October 13, 2026 17:31
vepadulano
approved these changes
Oct 14, 2026
vepadulano
left a comment
Member
There was a problem hiding this comment.
A great improvement in ergonomics for Python users, thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This Pull request:
Now that #21261 landed, Python callables can be passed to C++ templated functions directly.
We apply this in
RDataFrame: from now on, a Python function passed toDefineorFilterwithout a decorator runs as it is in the Python interpreter. RDataFrame no longer compiles it with Numba behind the scenes. You can use any Python code in it, including ROOT classes and their methods, and any Python library:The function needs type annotations: RDataFrame reads them to know the C++ types of the parameters and of the return value. These can be C++ type names, Python types or ROOT classes. A function without annotations raises.
Numba stays available as an opt in, with the same
ROOT.Numba.Declaredecorator as before:Note
extra_argsis now only supported for Numba decorated functions. Plain Python functions can use variables from the surrounding code instead.