This package enables to persist information stored in dataclasses.
Project description
This program can be used to make dataclasses persistent by adding store and load functionality. The dataclass is stored in .json format which is by default compressed inside of a .zip file.
- What makes dataclass-persistence special?
Support for numpy arrays
Support for nested dataclasses
Human readable storage format with small file size
Usage
Let your dataclass inherit from Persistent.
Then the dataclass can be stored on disk using .store() and loaded from disk using
.load().
In the example below, we create an instance of dataclass, which is stored to and loaded from disk.
from dataclass_persistence import Persistent
from dataclasses import dataclass
import numpy as np
@dataclass
class SomeData(Persistent):
parameter_a: str
array: np.ndarray
data = SomeData('my_string', np.array([0, 0]))
file = 'my_file'
data.store(file)
data_reconstructed = SomeData.load(file)
On disk the code above produces my_file.zip which contains my_file.json:
{
"parameter_a": "my_string",
"array": {"data": [0, 0], "dtype": "int32"}
}
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dataclass-persistence-0.0.18.tar.gz.
File metadata
- Download URL: dataclass-persistence-0.0.18.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
617de67eb1c8a243bc14c1ad4225036ae3d7a36efacf10a74d54609327b7cb5f
|
|
| MD5 |
78f19afeda879e2f8f7377ee289297b6
|
|
| BLAKE2b-256 |
a0bae0021b8a0fd913e21fffad113607b41b380b297361296a15a5725f87e5d9
|
File details
Details for the file dataclass_persistence-0.0.18-py3-none-any.whl.
File metadata
- Download URL: dataclass_persistence-0.0.18-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfb4001b05b50e0cc7050aa6f23fe823ce61fc3d1738b9d4b8ae71199d361749
|
|
| MD5 |
1294b429b4d73d8a7f7681e5572e6a7b
|
|
| BLAKE2b-256 |
5358eb8469f913692f8e4bb12ed0fcc845d4a912de41d9336c126f4286364c88
|