pythonize icon indicating copy to clipboard operation
pythonize copied to clipboard

Support serialising to named mappings

Open juntyr opened this issue 1 year ago • 5 comments
trafficstars

This PR includes four changes:

  • Implement PythonizeListType for PyTuple, a small convenience that cannot be achieved outside the crate
  • Add support for prebuilding mappings during serialisation, which delays the collection of mapping key-value pairs until all are known
  • Add support for named mappings during serialisation, which adds a tiny default-implemented helper trait method to pass forward the struct / tuple / enum name to the mapping type
  • Allow deserializing an enum from any mapping instead of just dicts

I have found them to be very useful to serialise to and from class-like Python types (e.g. namedtuple which keep more type information around).

juntyr avatar May 18 '24 04:05 juntyr