madman-bob / python-dataclasses-serialization

Serialize/deserialize Python dataclasses to various other data formats
MIT License
25 stars 11 forks source link

Handle tuples #19

Open petered opened 1 year ago

petered commented 1 year ago

Adds Tuple-handling to the JSONSerializer, using a tuple_deserialization function that will also make it easier for custom serialisers to handle tuples.

Also adds documentation and type-annotations to the Serializer class and the enigmatic RefinementDict.

petered commented 1 year ago

Hey @madman-bob . I was looking to make a nice general-purpose tool for python serialisation in the coming months, as it seems that serialization is one of those things where people constantly re-invent the wheel. So I was happy to find your PyPi package - which really provides a really nicely written foundation for this. I'm not sure to what extent you want to extend the scope of this package - there're a few things that I'd like to add. I can either add them to this repo, or to another repo with this repo as a dependency.

Can you me know which, if any, you'd consider taking them as PR's in your repo?

  1. This PR (allowing serialisation of, e.g. Tuple[int, str] in default JSONSerializer)
  2. Versioning support (basically a clear protocol for handling backwards/forwards compatibility when your data class changes fields but you still want to be able to load past/future files with current code).
  3. Support for putting multiple objects in a single file, which can be read sequentially and lazily (e.g. read metadata without reading data, or lazily read a stream without reading whole stream on start)
  4. Numpy support (would involve adding numpy, msgpack, msgpack_numpy dependencies)