{"id":15481668,"url":"https://github.com/yushiomote/perde","last_synced_at":"2025-04-22T15:42:09.392Z","repository":{"id":55779353,"uuid":"290764929","full_name":"YushiOMOTE/perde","owner":"YushiOMOTE","description":"Python serialization framework powered by Rust","archived":false,"fork":false,"pushed_at":"2020-12-12T08:15:12.000Z","size":3967,"stargazers_count":26,"open_issues_count":8,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T23:46:37.838Z","etag":null,"topics":["dataclasses","json","messagepack","python","serialization","toml","typing","yaml"],"latest_commit_sha":null,"homepage":"https://yushiomote.github.io/perde","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YushiOMOTE.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-27T12:06:57.000Z","updated_at":"2025-02-19T07:55:54.000Z","dependencies_parsed_at":"2022-08-15T07:00:47.558Z","dependency_job_id":null,"html_url":"https://github.com/YushiOMOTE/perde","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YushiOMOTE%2Fperde","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YushiOMOTE%2Fperde/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YushiOMOTE%2Fperde/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YushiOMOTE%2Fperde/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YushiOMOTE","download_url":"https://codeload.github.com/YushiOMOTE/perde/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249273970,"owners_count":21242004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dataclasses","json","messagepack","python","serialization","toml","typing","yaml"],"created_at":"2024-10-02T05:05:25.478Z","updated_at":"2025-04-16T20:32:14.101Z","avatar_url":"https://github.com/YushiOMOTE.png","language":"Rust","readme":"# perde: python-wrapped serde\n\n### Heavily under construction towards 0.1.0 🎅\n\n[![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![PyPi](https://img.shields.io/pypi/v/perde.svg)](https://pypi.python.org/pypi/perde)\n[![Supported python versions](https://img.shields.io/pypi/pyversions/perde.svg)](https://pypi.org/project/perde/)\n[![Actions Status](https://github.com/YushiOMOTE/perde/workflows/tests/badge.svg)](https://github.com/YushiOMOTE/perde/actions)\n[![codecov](https://codecov.io/gh/yushiomote/perde/branch/master/graph/badge.svg)](https://codecov.io/gh/yushiomote/perde)\n[![Coding style](https://badgen.net/badge/code%20style/black/000)](https://github.com/ambv/black)\n\n![](https://github.com/YushiOMOTE/perde/blob/master/assets/logo.png?raw=true)\n\nPython wrapper around [the powerful Rust serialization framework](https://github.com/serde-rs/serde).\n\n* Serialization \u0026 deserialization of python data structures.\n* Supports various types including dataclasses, generic types, enum and common built-in types.\n* Supports various serialization formats. By design, `perde` can support as many format as `serde` can.\n* Provides string case conversion of field names, skipping serialization/deserialization options, structure flattening.\n* Precise type checking based on type hints.\n* Very fast.\n\n\u003c!--\n\u003e\u003e\u003e from dataclasses import dataclass, field\n\u003e\u003e\u003e import enum\n\n--\u003e\n\n\n### Install\n\n```sh\npip install perde\n```\n\n### Usage\n\n```python\n\u003e\u003e\u003e import perde\n\n```\n\nAssume you have a dataclass,\n\n```python\n\u003e\u003e\u003e @dataclass\n... class A:\n...     a: int\n...     b: str\n\n```\n\nTo serialize class `A` to JSON,\n\n```python\n\u003e\u003e\u003e perde.json.dumps(A(a=10, b='x'))\n'{\"a\":10,\"b\":\"x\"}'\n\n```\n\nTo deserialize JSON to class `A`,\n\n```python\n\u003e\u003e\u003e perde.json.loads_as(A, '{\"a\":10,\"b\":\"x\"}')\nA(a=10, b='x')\n\n```\n\nTo deserialize JSON to a dictionary,\n\n```python\n\u003e\u003e\u003e perde.json.loads('{\"a\":10,\"b\":\"x\"}')\n{'a': 10, 'b': 'x'}\n\n```\n\nMore formats are supported.\n\n```python\n\u003e\u003e\u003e perde.yaml.dumps(A(10, \"x\"))\n'---\\na: 10\\nb: x'\n\u003e\u003e\u003e perde.yaml.loads_as(A, '---\\na: 10\\nb: x')\nA(a=10, b='x')\n\u003e\u003e\u003e perde.msgpack.dumps(A(10, \"x\"))\nb'\\x82\\xa1a\\n\\xa1b\\xa1x'\n\u003e\u003e\u003e perde.msgpack.loads_as(A, b'\\x82\\xa1a\\n\\xa1b\\xa1x')\nA(a=10, b='x')\n\n```\n\n### Supported formats\n\n* [x] JSON (`perde.json`)\n* [x] YAML (`perde.yaml`)\n* [x] MessagePack (`perde.msgpack`)\n* [x] TOML (`perde.toml`)\n* [ ] CBOR\n* [ ] Pickle\n* [ ] RON\n* [ ] BSON\n* [ ] Avro\n* [ ] JSON5\n* [ ] Postcard\n* [ ] URL\n* [ ] Environment variables\n* [ ] AWS Parameter Store\n* [ ] S-expressions\n* [ ] D-Bus\n* [ ] FlexBuffer\n* [ ] XML\n\n### Supported types\n\n* `dataclass`\n* Primitive types\n    * `int`\n    * `str`\n    * `float`\n    * `bool`\n    * `bytes`\n    * `bytearray`\n* Generic types\n    * `dict` /`typing.Dict`\n    * `list` / `typing.List`\n    * `set` / `typing.Set`\n    * `frozenset` / `typing.FrozenSet`\n    * `tuple` / `typing.Tuple`\n    * `typing.Optional`\n    * `typing.Union`\n    * `typing.Any`\n* Enum types\n    * `Enum`\n    * `IntEnum`\n    * `Flag`\n    * `IntFlag`\n* More built-in types\n    * `datetime.datetime`\n    * `datetime.date`\n    * `datetime.time`\n    * `decimal.Decimal`\n    * `uuid.UUID`\n\n### Attributes\n\nAttributes allow to modify the way of serialization/deserialization.\n\nFor example, to serialize/deserialize the field names as `camelCase`,\n\n```python\n\u003e\u003e\u003e @perde.attr(rename_all=\"camelCase\")\n... @dataclass\n... class A:\n...     foo_bar: int\n...     bar_bar: int\n\n\u003e\u003e\u003e perde.json.dumps(A(foo_bar=1, bar_bar=2))\n'{\"fooBar\":1,\"barBar\":2}'\n\u003e\u003e\u003e perde.json.loads_as(A, '{\"fooBar\":1,\"barBar\":2}')\nA(foo_bar=1, bar_bar=2)\n\n```\n\nSee [the book](https://yushiomote.github.io/perde/attributes.html) for more details.\n\n### Benchmark\n\n\u003cimg src=\"https://github.com/YushiOMOTE/perde/blob/master/assets/serialize_json_data_a.svg?raw=true\" /\u003e\n\u003cimg src=\"https://github.com/YushiOMOTE/perde/blob/master/assets/deserialize_json_data_a.svg?raw=true\" /\u003e\n\u003cimg src=\"https://github.com/YushiOMOTE/perde/blob/master/assets/serialize_msgpack_data_a.svg?raw=true\" /\u003e\n\u003cimg src=\"https://github.com/YushiOMOTE/perde/blob/master/assets/deserialize_msgpack_data_a.svg?raw=true\" /\u003e\n\nThe benchmark repeats (de)serializing the data structure `A` 10000 times:\n\n```python\nclass A:\n    a: int\n    b: str\n    c: float\n    d: bool\n```\n\n* [pyserde](https://github.com/yukinarit/pyserde)\n* [mashumaro](https://github.com/Fatal1ty/mashumaro)\n* [attrs](https://github.com/python-attrs/attrs)\n* [cattrs](https://github.com/Tinche/cattrs)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyushiomote%2Fperde","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyushiomote%2Fperde","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyushiomote%2Fperde/lists"}