Fast and flexible serialization library.
Project description
perde: python-wrapped serde
Heavily under construction towards 0.1.0 🎅
Python wrapper around the powerful Rust serialization framework.
- Serialization & deserialization of python data structures.
- Supports various types including dataclasses, generic types, enum and common built-in types.
- Supports various serialization formats. By design,
perde
can support as many format asserde
can. - Provides string case conversion of field names, skipping serialization/deserialization options, structure flattening.
- Precise type checking based on type hints.
- Very fast.
Install
pip install perde
Usage
>>> import perde
Assume you have a dataclass,
>>> @dataclass
... class A:
... a: int
... b: str
To serialize class A
to JSON,
>>> perde.json.dumps(A(a=10, b='x'))
'{"a":10,"b":"x"}'
To deserialize JSON to class A
,
>>> perde.json.loads_as(A, '{"a":10,"b":"x"}')
A(a=10, b='x')
To deserialize JSON to a dictionary,
>>> perde.json.loads('{"a":10,"b":"x"}')
{'a': 10, 'b': 'x'}
More formats are supported.
>>> perde.yaml.dumps(A(10, "x"))
'---\na: 10\nb: x'
>>> perde.yaml.loads_as(A, '---\na: 10\nb: x')
A(a=10, b='x')
>>> perde.msgpack.dumps(A(10, "x"))
b'\x82\xa1a\n\xa1b\xa1x'
>>> perde.msgpack.loads_as(A, b'\x82\xa1a\n\xa1b\xa1x')
A(a=10, b='x')
Supported formats
- JSON (
perde.json
) - YAML (
perde.yaml
) - MessagePack (
perde.msgpack
) - TOML (
perde.toml
) - CBOR
- Pickle
- RON
- BSON
- Avro
- JSON5
- Postcard
- URL
- Environment variables
- AWS Parameter Store
- S-expressions
- D-Bus
- FlexBuffer
- XML
Supported types
dataclass
- Primitive types
int
str
float
bool
bytes
bytearray
- Generic types
dict
/typing.Dict
list
/typing.List
set
/typing.Set
frozenset
/typing.FrozenSet
tuple
/typing.Tuple
typing.Optional
typing.Union
typing.Any
- Enum types
Enum
IntEnum
Flag
IntFlag
- More built-in types
datetime.datetime
datetime.date
datetime.time
decimal.Decimal
uuid.UUID
Attributes
Attributes allow to modify the way of serialization/deserialization.
For example, to serialize/deserialize the field names as camelCase
,
>>> @perde.attr(rename_all="camelCase")
... @dataclass
... class A:
... foo_bar: int
... bar_bar: int
>>> perde.json.dumps(A(foo_bar=1, bar_bar=2))
'{"fooBar":1,"barBar":2}'
>>> perde.json.loads_as(A, '{"fooBar":1,"barBar":2}')
A(foo_bar=1, bar_bar=2)
See the book for more details.
Benchmark
JSON
YAML
TOML
MessagePack
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file perde-0.0.2.tar.gz
.
File metadata
- Download URL: perde-0.0.2.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c050211422cf8bdca8f6a22f5557d394f346e017440dee2f208184cbc3a274f |
|
MD5 | 854439c8e0bf54ac7b60dca6b0204ad7 |
|
BLAKE2b-256 | cca0bf99beeb5a4d7320513eab8230d6e9bfceda056a4311bfe908952da618db |
File details
Details for the file perde-0.0.2-cp39-none-win_amd64.whl
.
File metadata
- Download URL: perde-0.0.2-cp39-none-win_amd64.whl
- Upload date:
- Size: 550.7 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78a042091feda95817db82cbf063e29b0e47ba9e5b2def25d959a4e9bf7f8fce |
|
MD5 | 07bf510d911f2f235866bd8c6aaf69a9 |
|
BLAKE2b-256 | c8cf294cdaa7f89f7afec2c2de5a2100599bfbf2ee6fa1f1b0b6cca8ef1cd316 |
File details
Details for the file perde-0.0.2-cp39-cp39-manylinux2010_x86_64.whl
.
File metadata
- Download URL: perde-0.0.2-cp39-cp39-manylinux2010_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfdf291f9d20e0137b8fdf5c6e7ebf5924270c33bde0bf36f64f60859ab9663e |
|
MD5 | a4979b1fc490565d6a195344783beb49 |
|
BLAKE2b-256 | a9fbf640bd0aa0b499cd7b87032bff59f4c4f4c7cbfea840b65111c9e7712084 |
File details
Details for the file perde-0.0.2-cp39-cp39-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: perde-0.0.2-cp39-cp39-macosx_10_7_x86_64.whl
- Upload date:
- Size: 660.6 kB
- Tags: CPython 3.9, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dc9e9ba18fe29f4d57e2bc10f776f69658dcb3342003b1e216f65c2400b5c2b |
|
MD5 | 1ee761d365be2c71f32ed5b3069bfb37 |
|
BLAKE2b-256 | f582114e503587de21147f0480a3591adbd99ae22934d3cdfc78d161fe623c99 |
File details
Details for the file perde-0.0.2-cp38-none-win_amd64.whl
.
File metadata
- Download URL: perde-0.0.2-cp38-none-win_amd64.whl
- Upload date:
- Size: 550.7 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1b1db7942af3bed3b495eb988199e9bee080d45d67af5f3c08b2a4b8d28f229 |
|
MD5 | fdabeee989f04eb18ceb72e40c9acb45 |
|
BLAKE2b-256 | 4daa08fe7704b9a10cd2fcfdf7f2d3fd345f4d0767eaa3516ca678b2c871f288 |
File details
Details for the file perde-0.0.2-cp38-cp38-manylinux2010_x86_64.whl
.
File metadata
- Download URL: perde-0.0.2-cp38-cp38-manylinux2010_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 488bb307352526a82b4db4b2b10149f196dad6a263e6bf773c3a21f3185e75e0 |
|
MD5 | b38ade49120842afa8343183f3333e5f |
|
BLAKE2b-256 | 4b006bb5a33bd1dc4c81987e6ef339a032117058107f43b400f875a9e3b0a1c8 |
File details
Details for the file perde-0.0.2-cp38-cp38-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: perde-0.0.2-cp38-cp38-macosx_10_7_x86_64.whl
- Upload date:
- Size: 660.5 kB
- Tags: CPython 3.8, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a8ddcc3792ce751f1e8647dfc19306d3044a52bf968f5961da5a700749174fe |
|
MD5 | 030f27c2ba16947d2e75146e23f6a498 |
|
BLAKE2b-256 | 7609fc137eb54b90fc6f8b405cf2139a9c53f0091cb06f27d2bed0a07eebc118 |
File details
Details for the file perde-0.0.2-cp37-none-win_amd64.whl
.
File metadata
- Download URL: perde-0.0.2-cp37-none-win_amd64.whl
- Upload date:
- Size: 550.7 kB
- Tags: CPython 3.7, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7dc2f1ed295796b3a3082d7bb4a8aeddb3705e7d37027c5c65e9461a0f170bb |
|
MD5 | 69acef428c1da8ae9e2e01d96a44cdd2 |
|
BLAKE2b-256 | 938aad94742cf04ced4f4379264a6a0177a5ba001533bf7da55c47b2c82d2b6a |
File details
Details for the file perde-0.0.2-cp37-cp37m-manylinux2010_x86_64.whl
.
File metadata
- Download URL: perde-0.0.2-cp37-cp37m-manylinux2010_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f57914ea4ff066319b08fd156807ac06444862fb4feeae654b7478e6e1400324 |
|
MD5 | 31876a941eefb690b7ddbc7126e48629 |
|
BLAKE2b-256 | 528d66617712f935a5e24ce57d6ceb83459770be8fe69e04e9d091fa8063b16a |
File details
Details for the file perde-0.0.2-cp37-cp37m-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: perde-0.0.2-cp37-cp37m-macosx_10_7_x86_64.whl
- Upload date:
- Size: 660.6 kB
- Tags: CPython 3.7m, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e59d09cbcb9abe10e8a2f7f5100d7452fdd44477d44f992e13c8743d09c66f0 |
|
MD5 | b1b54954ff29a8475ab4279944fe3b7b |
|
BLAKE2b-256 | 8a9d1b79aa8a1e31cca31888260e379dc8b4319053f127184dc2aef62a720c57 |