-
I just want to be certain about what aspect of multiple inheritance is not part of nanobind (vs pybind11), is it on the python side? As in, I cannot define a python class as:
where |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
This is correct. It will currently fail with the exception
It is possible that multiple inheritance on the Python side could be handled when the underlying class hierarchy doesn't mix in more than one C++-based class. I have not though too much about this special case since none of my own projects need it. I am open to PRs in this regard if's just a matter of relaxing that condition without adding further complexity/performance cost to the project. |
Beta Was this translation helpful? Give feedback.
-
Just wanted to add another consideration point to this. I am trying to implement a pandas extension array using nanobind, which requires third parties to subclass their own ABC to properly register an extension. Getting rid of the base class "check" in nanobind hacks things together in the simple case: from my_ext import ArrayClass # assume this is from a nanobind compiled extension
from pandas.api.extensions import ExtensionArray
class NanobindArray(ArrayClass, ExtensionArray):
... But the limitation I am running into is that the pandas extension interface will apply an algorithm to my >>> arr = NanobindArray()
>>> res = pd.some_algorithm(arr)
>>> type(res)
ArrayClass # ideally need back an ExtensionArray Though I am guessing there is no simple way to express this type of multiple inheritance from a mix of nanobind/Python classes in the extension itself |
Beta Was this translation helpful? Give feedback.
This is correct. It will currently fail with the exception
It is possible that multiple inheritance on the Python side could be handled when the underlying class hierarchy doesn't mix in more than one C++-based class. I have not though too much about this special case since none of my own projects need it. I am open to PRs in this regard if's just a matter of relaxing that condition without adding further complexity/performance cost to the project.