-
// c++ code
class Base {
public:
...
Base getitem(int idx);
} // bind to python
nb::class_<Base>(m, "Base")
.def("getitem", &Base::getitem); # python code
from xxx import Base
class Derived(Base):
def __getitem__(self, idx):
return self.getitem(idx)
def some_fn(self, *args):
...
foo = Derived()
bar = a[0] Finally, type( |
Beta Was this translation helpful? Give feedback.
Answered by
wjakob
Aug 5, 2024
Replies: 1 comment 3 replies
-
Not if returning by-value. In this case, a copy is made that forgets its Python identity. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually, let me fix that.