How to implement IntoPyObject for a class which extends a base class? #4955
-
The docs for IntoPyObject quite tantalisingly say
But I didn't find anywhere a description of how to deal with a class which does extend a base class. Here's my class
and here's my legacy conversion which works nicely in PyO3 0.22, which I need to adapt to use
And
I could really do with a pointer towards how to do this now! In case it helps, my source code is here. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Since you already use Previously |
Beta Was this translation helpful? Give feedback.
Since you already use
Py::new
you already have a Python object and there is no need to useIntoPyObject
. You should be able to justreplace your
into_py
call withinto_any
to remove the type info.Previously
IntoPy
forPy
was just throwing away the type information.IntoPyObject
is also implemented forPy
but now keeps the type information.IntoPyObjectExt
also provides a few helpers for common type conversions.