davidhewitt / pythonize

MIT License
200 stars 27 forks source link

Implement serialize, update tests #2

Closed ptous closed 3 years ago

ptous commented 4 years ago

Updates to the latest pyo3, implements Serialize and updates tests to account for it.

This is a pretty small change set, but I'm a relatively new Rust developer so it's possible I'm doing silly things. Feedback quite welcome.

This has seen active use in one of my own projects, adapting this project to serialize its output into Python dicts. Originally I approached this with dict-derive, but serde's control over field attributes and serialization paths was much more effective. Without that level of control, repeated reference counted fields were being re-serialized to Python many thousands of times. I could have created stripped-down copies of the structs I was after and serialized those instead, but using serde eliminates the need to maintain two sets of structs as things evolve.

I didn't need to implement Deserialize so I haven't yet, but I could use it in my project, so I might yet take a stab. If I do, I'll PR that as well.

davidhewitt commented 3 years ago

Thanks again for this PR, I've made the suggested changes and merging now. 🚀