No project description provided
Project description
serpyco-rs: a serializer for python dataclasses
What is serpyco-rs ?
Serpyco is a serialization library for Python 3.9+ dataclasses that works just by defining your dataclasses:
import dataclasses
import serpyco_rs
@dataclasses.dataclass
class Example:
name: str
num: int
tags: list[str]
serializer = serpyco_rs.Serializer(Example)
result = serializer.dump(Example(name="foo", num=2, tags=["hello", "world"]))
print(result)
>> {'name': 'foo', 'num': 2, 'tags': ['hello', 'world']}
serpyco-rs works by analysing the dataclass fields and can recognize many types : list
, tuple
, Optional
...
You can also embed other dataclasses in a definition.
The main use-case for serpyco-rs is to serialize objects for an API, but it can be helpful whenever you need to transform objects to/from builtin Python types.
Installation
Use pip to install:
$ pip install serpyco-rs
Features
- Serialization and unserialization of dataclasses
- Validation of input/output data
- Very fast
- Support recursive schemas
Supported field types
There is support for generic types from the standard typing module:
- Decimal
- UUID
- Time
- Date
- DateTime
- Enum
- List
- Dict
- Mapping
- Sequence
- Tuple (fixed size)
Benchmark
macOS Monterey / Apple M1 Pro / 16GB RAM / Python 3.11.0
dump
Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
---|---|---|---|
serpyco_rs | 0.05 | 22188.2 | 1 |
serpyco | 0.05 | 20878.5 | 1.06 |
mashumaro | 0.06 | 15602.7 | 1.42 |
pydantic | 2.66 | 375.6 | 59 |
marshmallow | 1.05 | 951.7 | 23.33 |
load with validate
Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
---|---|---|---|
serpyco_rs | 0.23 | 4400.1 | 1 |
serpyco | 0.28 | 3546.4 | 1.24 |
mashumaro | 0.23 | 4377.7 | 1.01 |
pydantic | 2.01 | 497.3 | 8.86 |
marshmallow | 4.55 | 219.9 | 20.03 |
load (only serpyco and serpyco_rs supported load without validate)
Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
---|---|---|---|
serpyco_rs | 0.07 | 13882.9 | 1 |
serpyco | 0.08 | 12424.5 | 1.12 |
mashumaro | 0.23 | 4382.9 | 3.17 |
pydantic | 2.02 | 494.4 | 28.09 |
marshmallow | 4.59 | 217.5 | 63.8 |
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
serpyco_rs-0.2.2.tar.gz
(32.1 kB
view hashes)
Built Distributions
Close
Hashes for serpyco_rs-0.2.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e29b2564676380dc65135baa77128c8111cdecd29f4d2e0818a1e102ca461ba |
|
MD5 | 6dbc6368a7a4769b417d543ca8fbc478 |
|
BLAKE2b-256 | 6b1949e8758235b0e5dcf6d3619c694768270f7127589d69d30f87b9b35fcc70 |
Close
Hashes for serpyco_rs-0.2.2-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a00f5791db49d1ca9f19a200c528bad977192276c676f76b5b086842a65bfccc |
|
MD5 | d494ed4a3de8faa682c6e2766dc3c458 |
|
BLAKE2b-256 | 34a2ded804c9c08b5809e77c9c9fc27c6c3ba920d50cb07df1aa66ae489c1d98 |
Close
Hashes for serpyco_rs-0.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bc43d085254eb94c2b71e32a05176e999ef6183c166e4ce7ce7ca37c5e0f8b8 |
|
MD5 | 471ec39c2cd6a3bc875d7f59f4338866 |
|
BLAKE2b-256 | 6a5b6517d0d12ba106788c07a73068e379f603e298a11981d8acb05c3ca3215b |
Close
Hashes for serpyco_rs-0.2.2-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f50d59b3068a97c11f21717a070ebaebca0d81d0d932b5747d10cffeee3037b |
|
MD5 | 3c8395e711f2a895e0b5d87b16d63bca |
|
BLAKE2b-256 | b60dc897915c7b2895acbbea0594d3f1c777b6361191d4e67be5cf0a0642aa5e |
Close
Hashes for serpyco_rs-0.2.2-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecf800efbf7dbe285522cf85bd3e3e1abd5a569d31aa1ab56888d79154282498 |
|
MD5 | 3579a414f19fcf961eb316891ed4dc46 |
|
BLAKE2b-256 | 870c10b59653a4e566b773c9d21b25c6ae6369d1646ce1b68a574e3f3e083d28 |
Close
Hashes for serpyco_rs-0.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22ab2a0a6cc767f28dde0f32429fc605f7ca324b6ba4533951bf4dfab9822a33 |
|
MD5 | 2f296655859656b95c2ba6e613843c6d |
|
BLAKE2b-256 | 0c347a2302ac1ce5d2fc5cabd12302c7a4ae66049441abd4bd05dc3d638f5062 |
Close
Hashes for serpyco_rs-0.2.2-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2104593a7a44d462734f0618cfd73b4f5a34866a84d5f731bcfca732c9fc86b9 |
|
MD5 | 77f9d7e044f66efd4878cedd638d4c3b |
|
BLAKE2b-256 | 35d5cbec0c00d0bea1963a3ab3ed18b16f9bbe2228e96d09d82f0de62c39f8c0 |
Close
Hashes for serpyco_rs-0.2.2-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8efdf1be86bb874397f837b2bb6ee53b3d2154c5d4a666ada43c2565a33f8383 |
|
MD5 | 30487e6d82ed158ac3d5ec1922dbdb2f |
|
BLAKE2b-256 | 4d3ce79b576b267746abd3631979d8b1b671ec0960926fcdf5ea8385c98c2d60 |
Close
Hashes for serpyco_rs-0.2.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8def35b6eff2dcf30de1ebc5edcc7ead0263b3195eb9e47cdefc42f1ef435ac0 |
|
MD5 | c586588032ed1f88358b68fa081011c4 |
|
BLAKE2b-256 | f65f4f70769f464ec2dcad083a8d0a8b4a585dc4eb976e17e54bed84138f6d15 |
Close
Hashes for serpyco_rs-0.2.2-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f7e075510f6aee629e4c5d60438beb579474410fe29d0a6ab9b3e585e869722 |
|
MD5 | c1da60757308e6e617736fc5aeebec69 |
|
BLAKE2b-256 | 2fb8cae08a09f24f4f115eddd5bad4a925df6ba93e9db6b6738bc09faef9f2e0 |