dataclass_toolkit
Minimalistic utilities for working with Python
dataclass— serialize, deserialize, and compactly store dataclass instances.
Installation
pip install dataclass_toolkit
What is dataclass_toolkit?
dataclass_toolkit provides lightweight tools to work with Python dataclasses:
- Convert dataclass instances into compact lists.
- Restore dataclasses from lists.
- Handle nested dataclasses and lists of dataclasses automatically.
- Save and transmit dataclass data in the most compact way.
Example Usage
from dataclasses import dataclass
from dataclass_toolkit.as_list import serialize_dataclass_to_list, deserialize_list_to_dataclass
@dataclass
class Child:
x: int
y: str
@dataclass
class Parent:
a: int
b: Child
c: list[Child]
# Create an object
p = Parent(
a=1,
b=Child(x=10, y="hello"),
c=[Child(x=20, y="world")]
)
# Serialize to list
data = serialize_dataclass_to_list(p)
print(data)
# Output: [1, [10, 'hello'], [[20, 'world']]]
# Deserialize back
restored = deserialize_list_to_dataclass(Parent, data)
print(restored)
# Output: Parent(a=1, b=Child(x=10, y='hello'), c=[Child(x=20, y='world')])
🔥 Features
- ✅ Supports nested dataclasses
- ✅ Supports lists of dataclasses
- ✅ Compatible with
__slots__ - ✅ Minimal and efficient serialization
- ✅ Clean and extensible codebase
📜 License
This project is licensed under the MIT License — feel free to use it in your projects!
🤝 Contributing
Pull requests are welcome!
If you have ideas for improvements or new utilities, feel free to open an issue.
Metadata
Release files for dataclass-toolkit 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dataclass_toolkit-0.1.3.tar.gz | 5.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dataclass_toolkit-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.8 kB
Release files / dataclass_toolkit-0.1.3.tar.gz
| Download URL | dataclass_toolkit-0.1.3.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1c58bfe625ffa038dc11aba91805f70f7452c577a02ecd18cff2b1fb95ee3d2e
|
|
BLAKE2b-256 checksum How to use checksums |
9520dd8c33202c0da250ba29be4591585d59d9cd462bbb84c1a5c370e9bcb552
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / dataclass_toolkit-0.1.3-py3-none-any.whl
| Download URL | dataclass_toolkit-0.1.3-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d6b31af8e0f9de960e582dfd59992591433632e7caf57ea0a518579d7c59a9a5
|
|
BLAKE2b-256 checksum How to use checksums |
25020c7179872aec6afb12d0019968050c55482fab877ce7b7c5089b00a449ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|