You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, it seems like this pattern was deliberately left out of the nanobind docs. I'm also not sure how it interacts with the NB_TRAMPOLINE macros.
Is this pattern no longer recommended? Are there any edge case differences between how pybind11/nanobind handles trampoline classes that would break it with a more complicated set up? Would it break how nanobind infers inheritance information?
Note that I am migrating a pybind11 project to nanobind which used this pattern extensively.
Side question: Our current pybind11 project uses trampoline classes to store py::object variables, which seems to work fine right now. Would any differences in nanobind break this?
Edit: looking at the implementation of NB_TRAMPOLINE maybe you should instead do this?
Edit 2: it doesn't work, I don't know why. I tried a few different variants, the error messages make no sense to me.
Edit 3: I think this works? Had to learn about C++ behavior for unqualified names from dependent base class, and shadowing of redeclared class instance variables... Perhaps the NB_TRAMPOLINE macro can be changed to accommodate this pattern?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In the pybind11 docs, we're given an example of having inheritance between trampoline classes:
https://pybind11.readthedocs.io/en/latest/advanced/classes.html#combining-virtual-functions-and-inheritance
I tested a toy example in nanobind and it seems to work:
However, it seems like this pattern was deliberately left out of the nanobind docs. I'm also not sure how it interacts with the
NB_TRAMPOLINE
macros.Is this pattern no longer recommended? Are there any edge case differences between how pybind11/nanobind handles trampoline classes that would break it with a more complicated set up? Would it break how nanobind infers inheritance information?
Note that I am migrating a pybind11 project to nanobind which used this pattern extensively.
Side question: Our current pybind11 project uses trampoline classes to store
py::object
variables, which seems to work fine right now. Would any differences in nanobind break this?Edit: looking at the implementation of
NB_TRAMPOLINE
maybe you should instead do this?does this work?
Edit 2: it doesn't work, I don't know why. I tried a few different variants, the error messages make no sense to me.
Edit 3: I think this works? Had to learn about C++ behavior for unqualified names from dependent base class, and shadowing of redeclared class instance variables... Perhaps the
NB_TRAMPOLINE
macro can be changed to accommodate this pattern?Beta Was this translation helpful? Give feedback.
All reactions