Open taehyounpark opened 7 months ago
Are there plans/work in progress for ROOT to move to a newer cppyy anytime soon?
Hi @taehyounpark! We have recently upgraded the cppyy frontend in ROOT, which will be part of ROOT 6.32: https://github.com/root-project/root/pull/14507
However, it doesn't fix this reproducer. I suspect that this also requires to synchronize the cppyy-backend. The problem is that this backend is a fork of ROOT itself, including cling. And then, cppyy made patches to this fork of cling/ROOT for e.g. better lambda support and other advanced C++ features and details of the type system.
The problem is that we can't take these patches 1 to 1 back to ROOT, because ROOT also used Cling for other things like IO, and the patches in cppyy did not have to consider compatibility with that.
We try to make cppyy independent of cling on the long term to solve this conundrum. In the meantime, I can see what we are exactly missing in upstream ROOT or Cling to make the reproducer in this issue work. Maybe it is an uncontroversial patch. This will also take some time though. I worked a lot on PyROOT in the last weeks and have to work on other responsibilities in the next weeks before coming back to this. Or maybe @wlav has a hint?
In the meantime, might there be anything I could try to "persuade" similar quirks, from either C++ or Python to make them work?
Unfortunately not. In ROOT, we don't use complicated template code with type traits in user interfaces. That's maybe my recommendation to you: can you simplify the user-facing interface and hide the templated stuff maybe behind some type-erased types or simplify it a bit? IMHO, templates are great for efficient implementations, but for user interfaces it can be a nightmare (think only about the error messages...).
You can look for std::function
in the git log, see whether there's anything easy to patch from there.
ROOT likes to strip std::
, which is problematic for non-HEP codes, so yes, I've pretty much completely removed that behavior from my fork of ROOT/meta. However, if memory serves, there was something worse with std::function
and templates. I think it's this one: https://github.com/wlav/cppyy-backend/commit/98c21db9fad90902efe71d92adc7735cba471c1f
There's also this bug report, which may be related: https://github.com/root-project/root/issues/10680 . (That issue does not exist with cppyy master.)
Thank you @guitargeek and @wlav for the quick and informative responses. These are totally understandable difficulties, and I'm looking forward to the future!
Unfortunately the usage of templates is quite baked-in for this library, which tries to allow users to write their own C++ classes and input (but also retrieve) them in a data analysis workflow. Ultimately, however, I guess this is not a complete showstopper as I could just resort to cppyy.cppdef()
where things work, and write a manual wrapper Python interface around it...
Check duplicate issues.
Description
Dear experts
I wanted to (1) point out two related bugs in ROOT's cppyy, and (2) ask for advice on how such cases are handled by ROOT developers.
First is a minimally reproducible bug involving pretty straightforward type trait gymnastics. The cppyy snippet below seems to simply gives up at the first non-trivial part, and no further Python bindings are possible.
The second, which I suspect is related/stems from the above, is cppyy sometimes "strips" the arguments of a function template parameter. As both pure-C++ and
cppyy.cppdef
do not make such mistakes (i.e. it's valid C++), I'm not sure what could be going wrong on the bindings-side to result in this behaviour. I have not been able to factorize this part out of my library to make a minimal example, but can be reproduced by with this header.Neither issue is present in the standalone, newer cppyy 3.0.0, so I suspect updating ROOT's cppyy 1.6.2 would solve the issue. So my call for help is:
Thank you very much for your time!
Reproducer
ROOT version
Installation method
build from source
Operating system
MacOS
Additional context
No response