-
The following example binds the base class Derivation from The functions Is there any way to make petPassThrough return its argument to Python without creating a new instance? Making petPassThrough expect a Python handle would not help me, because my application does not return arguments directly, but stores and returns them in/from a third-party library, using keep_alive to ensure that Python instances still exist when their C++ counterparts shall be returned. I am delighted by the run-time speed of nanobind. But being unable to return the original Python instances in this case would be a show stopper for me. So I'd be grateful for any advices. Having created an instance of that class derived in Python, nanobind's instance map Since it seems like a promising solution, and out of curiosity: why does C++ code:
Python code:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The reason is that you can have multiple instances with the same pointer address but different types. For example: struct Foo {
Bar b1;
Bar b2;
};
Foo f; Nanobind must be able to simultaneously access |
Beta Was this translation helpful? Give feedback.
Resolved via 716354f.