Open datapythonista opened 4 months ago
Did you ever find a solution to this problem?
Did you ever find a solution to this problem?
Unfortunately I couldn't find any workaround.
I ended up creating an IntoX(X)
wrapper and implementing FromPyObject
and Into<X>
for it. Seems to work well and feels quite elegant.
The root cause here is we have a generic blanket impl FromPyObject for T: PyClass + Clone
.
I think that blanket has caused unwelcome problems a few times now and creates subtle bugs, so I'm thinking we should consider removing. Just need to time it well around other breakages.
Bug Description
Seems intentional, but a
#[pyclass]
that implementsClone
automatically seems to implementFromPyObject
, which then can not be implemented again for my class.I have a struct (
Foo
in the example) that I want to use as a#[pyfunction]
argument and be able to receive many different Python types that will be converted in different ways to an instance ofFoo
. In my real case this is an expression in DataFusion which can be many custom classes or Python types. Things seem to work as expected, being able to implement the casting from the different types inFromPyObject
. Except that my class needs to implementClone
, and then I don't seem to have a way to define how objects are converted toFoo
.Steps to Reproduce
Backtrace