Yet another serialization library on top of dataclasses

pyserde

Yet another serialization library on top of dataclasses.

TL;DR

Put additional @serialize and @deserialize decorator in your ordinary dataclass.

@deserialize
@serialize
@dataclass
class Foo:
    i: int
    s: str
    f: float
    b: bool

Now you can convert an object to JSON,

>>> to_json(Foo(i=10, s='foo', f=100.0, b=True))
{"i": 10, "s": "foo", "f": 100.0, "b": true}

Converted back from JSON to the object quite easily!

>>> from_json(Foo, '{"i": 10, "s": "foo", "f": 100.0, "b": true}')
Foo(i=10, s='foo', f=100.0, b=True)

pyserde supports other data formats (YAML, Toml, MsgPack) and offers many more features!

Benchmark

  • macOS 10.14 Mojave
  • Intel 2.3GHz 8-core Intel Core i9
  • DDR4 32GB RAM

Serialize and deserialize a struct into and from json 10,000 times.

Serialize Deserialize
se-small

 

To finish reading, please visit source site