Best practices for mixed python/C++ APIs? #917
Unanswered
bethebunny
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Not sure if I can contribute much here. I don't think there is anything particularly objectionable about the monkey-patch approach you proposed. Can you give an example of the mixin strategy, I can't imagine what this looks like in practice. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I frequently find myself wanting to implement types in C++ that then have extended functionality in Python for richer pythonic interfaces. I haven't found a good way to implement this in pybind or nanobind.
__class__
which is IMO extremely bad practicenb::class_<Foo>(...)
; then in Python,def _foo_some_complex_fn(self, ...): ...; Foo.some_complex_fn = _foo_some_complex_fn
__class__
)Are there any other patterns folks have come up with? Does anything fit more naturally with Nanobind? Is there an easier way to "downcast" to your Python wrapper type that I'm not missing? Could Nanobind support these patterns better?
Beta Was this translation helpful? Give feedback.
All reactions