FastSerializer - 快速序列化器
用于将 Python 数据类对象序列化为 JSON 数据格式,也可以将JSON字典/字符串反序列化为 Python数据类对象。 原则上来说FastSerializer可以序列化任意对象。
注意:当前快速序列化器还未完成,请等此消息没有后再使用,但是可以进行测试。
✨ 特点
- 🚀快速:在Python提供非常高的性能因为它使用了dataclass,并且FastSerializer非常轻量,不占用太多空间。
- 💎优雅:精心设计,FastSerializer的设计模式可以让你减少冗余的代码。
- 📦简单:你可以定义合适的数据类结构,其它都交给FastSerializer和自定义的装饰器重写。
- 💪强大:支持任意复杂的对象(具有深度继承层次结构和泛型类型的)。
- 👍兼容:FastSerializer原始就支持很多其它的数据类库,比如:Pydantic、Dataclass、SqlalchemyOrm、自定义等。
📦 安装
$ pip install fast-serializer
💡 一个简单的例子
from typing import List
from fast_serializer import FastDataclass, field
class Address(FastDataclass):
"""地址"""
detail_address: str
class User(FastDataclass):
"""用户"""
nickname: str = field(required=True)
age: int = None
address_list: List[Address]
# 数据
data = {'nickname': 'Lao Da', 'address_list': [{'detail_address': 'China'}]}
# JSON字典到Python对象反序列化的用法
user = User(**data)
print(user) # 提供了Repr
print(user.nickname)
#> 'Lao Da'
👩💻 目录结构
fast_serializer
│ .gitignore git忽略文件
│ example.py 实例文件
│ README.md 阅读文件
└─fast_serializer 主包
│ constants.py 常量定义
│ dataclass_config.py 数据类的配置
│ decorators.py 装饰器
│ exceptions.py 异常
│ fast_dataclass.py 快速数据类
│ field.py 字段
│ getter.py Getter样板生成(待开发Pycharm插件后支持)
│ json_schema.py
│ serializer.py 序列化器
│ utils.py 工具包
│ validator.py 验证器
│ __init__.py
Metadata
Release files for fast-serializer 0.8.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| fast_serializer-0.8.4.tar.gz | 1.4 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fast_serializer-0.8.4-cp311-cp311-macosx_11_0_arm64.whl | CPython 3.11 | CPython 3.11 | macOS 11.0+ ARM64 | Details |
Total release size: 2.3 MB
Release files / fast_serializer-0.8.4.tar.gz
| Download URL | fast_serializer-0.8.4.tar.gz |
|---|---|
| Size | 1.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9c3e9284b727b7a29472ade67e8130211e9d4abd1cdf70666d122b0acb29e43a
|
|
BLAKE2b-256 checksum How to use checksums |
17b051a14560901c35c26efefa580bba4cfaf410437afbbc4cadc386c764aab3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Release files / fast_serializer-0.8.4-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | fast_serializer-0.8.4-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 952.8 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
efbdbb2b35d730820bb472fa747d2e21df4a165cf7c708ecaa69c9453ef95056
|
|
BLAKE2b-256 checksum How to use checksums |
b98b898265cb3a88c43db3bd70414e5886b8c4bc0e8e77584ccd22c4249f19fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Security for fast-serializer 0.8.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.