You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I may very well be implementing a weak design pattern, but I regularly use an enum to control Rust structs passed as Python classes. The enum itself does not need to be python class (so refutes the doc comment "The easiest way to implement IntoPy is by exposing a struct as a native Python object by annotating it with [#[pyclass]]")
The FromPyObject can be automatically derived, but I often implement IntoPy<PyObject> directly using repeatable boiler plate code such as the following. Can this be automatic in pyo3?
In PyO3 0.23 we are going to release a new trait IntoPyObject to replace IntoPy based on what we've learned over time. I would be open to discussing the possibility of adding an IntoPyObject derive too (not necessarily in 0.23, though that might be very appealing from the view of helping users migrate). cc @Icxolu
That sounds interesting and could be quite useful for migrating. For these newtype enums the conversion seems indeed quite straight forward, but for more complex enums and structs it's a bit unclear what the resulting Python object should be... maybe PyDict and/or PyTuple depending on whether the fields are named or not.
I may very well be implementing a weak design pattern, but I regularly use an
enum
to control Ruststructs
passed as Pythonclasses
. Theenum
itself does not need to be python class (so refutes the doc comment "The easiest way to implement IntoPy is by exposing a struct as a native Python object by annotating it with [#[pyclass]]")The
FromPyObject
can be automatically derived, but I often implementIntoPy<PyObject>
directly using repeatable boiler plate code such as the following. Can this be automatic in pyo3?The text was updated successfully, but these errors were encountered: