Mirror-bridge – Making Python bindings frictionless
Posted by fthiesen 6 days ago
Comments
Comment by kvemkon 5 days ago
I'm missing nanobind here.
> Method lookup. Python sees a.dot and searches for the dot attribute. It checks a.__dict__,
> Each attribute access (self.x) involves:
Dictionary lookup in self.__dict__
Since C++ classes are fixed, I'd expect attributes to be declared once in python (slots).One thing yet important for cross-language projects: callbacks (events). Would be nice if the sample could be extended.
Comment by fthiesen 5 days ago
Another thing that I can't make work elegantly is compiling template functions from C++, since we have no clue to guess which types will be instantiated in the Python code (and they can even depend on user input, so only determined at runtime)
Comment by dsp_person 6 days ago
> The Docker image includes clang-p2996, Bloomberg’s experimental Clang fork that implements the reflection proposal. As P2996 moves toward standardization, expect this to land in mainline compilers.
Possible to use that C++26 compiler just to do code generation for the binding code, and then use any other compiler for your actual build? I suppose alternatively could use a parser. Is the reflection code easy to work with in comparison? A year or two ago I spent some hours pulling my hair out trying to do some reflection in C++ until I gave up and spent the 20mins needed to write a python script to read my source files and do the code generation I needed.
Comment by fthiesen 5 days ago
Will add support for it as soon as I have some time to spare!
Comment by fthiesen 5 days ago
This idea of using C++26 compiler just for codegen sounds interesting. Will definitely give it some thought, thanks for the suggestion (:
Comment by a_t48 6 days ago
Comment by fthiesen 5 days ago
I want to make this project as mature as possible for when support arrives at the upstream version of clang, gcc and msvc. Feedback is appreciated!
Comment by just_mc 5 days ago
Comment by fthiesen 5 days ago