-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated pythonize
and pyo3
#401
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
The reason the pickle test fails is because of something that is different in the
Look carefully at the types in the json object. Before serialization, |
577c92e
to
3b3dc77
Compare
Yeah I concur with your breakdown that the serialization/deserialization cycle is considering the JSON's
Fwiw, going to How are you getting that printed representation with Also, |
If the |
I think it's important for What do you think of implementing a class Document:
...
def __eq__(self, other) -> bool:
if not isinstance(other, type(self)):
return NotImplemented
return self.to_dict() == other.to_dict() Also, it may be preferred to do this in |
Overriding
Good point. Perhaps we should make a reproducer of the issue using only pythonize, and ask from help from that project. |
I would be happy to do so, if you can point out how you printed the Also, just so I can understand, how do you know the issue is with |
From memory I put print statements somewhere. Hopefully I still have that code somewhere. I will check tomorrow. |
To print out that data, I added a print inside impl Document {
fn __richcmp__<'py>(
&self,
other: &Self,
op: CompareOp,
py: Python<'py>
) -> PyResult<Bound<'py, PyAny>> {
println!("\n\n\nComparing:\n\n{:?}\n\n{:?}", self.field_values, other.field_values);
match op {
CompareOp::Eq => {
let v = (self == other).into_pyobject(py)?.to_owned().into_any();
Ok(v)
},
CompareOp::Ne => {
let v = (self != other).into_pyobject(py)?.to_owned().into_any();
Ok(v)
},
_ => {
let v = PyNotImplemented::get(py).to_owned().into_any();
Ok(v)
}
}
}
} Tracing backwards from here, I also added some prints in the impl Document {
#[staticmethod]
fn _internal_from_pythonized(serialized: &Bound<PyAny>) -> PyResult<Self> {
println!("\n\n\nDeserializing: {:?}", serialized);
let out = pythonize::depythonize(serialized).map_err(to_pyerr);
let out: Document = out.unwrap();
println!("\n\n\nDeserialized: {:?}", out);
println!("\n\n\nDeserialized: {:?}", out.field_values);
Ok(out)
}
} So when I run the tests I get this stdout:
|
Okay I made jamesbraza#1, which:
I am not happy with this, but I am really in over my head here, so I made davidhewitt/pythonize#80 basically as a SOS. |
Perhaps |
@jamesbraza It would be great if you could add a very short reproducer to your issue on pythonize, so that David can easily run it and see the change in type during roundtrip. |
and
Don't worry, we're all learning all the time. Thanks for your continued interest in helping here ❤️ |
Closes #371