dataclass-persistence-0.2.1
توضیحات
This package enables to persist information stored in dataclasses.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | dataclass-persistence-0.2.1 |
| نام | dataclass-persistence |
| نسخه کتابخانه | 0.2.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | P.Mohr |
| ایمیل نویسنده | philipp.mohr@tuhh.de |
| آدرس صفحه اصلی | https://github.com/philipp-mohr/dataclass-persistence |
| آدرس اینترنتی | https://pypi.org/project/dataclass-persistence/ |
| مجوز | MIT |
dataclass-persistence
==========================
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 :code:`Persistent`.
Then the dataclass can be stored on disk using :code:`.store()` and loaded from disk using
:code:`.load()`.
In the example below, we create an instance of dataclass, which is stored to and loaded from disk.
.. code-block:: python
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`:
.. code-block:: json
{
"parameter_a": "my_string",
"array": {"data": [0, 0], "dtype": "int32"}
}
نیازمندی
| مقدار | نام |
|---|---|
| - | numpy |
| - | StrEnum |
| - | pytest |
| - | check-manifest |
| - | twine |
| - | wheel |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.10.0 | Python |
نحوه نصب
نصب پکیج whl dataclass-persistence-0.2.1:
pip install dataclass-persistence-0.2.1.whl
نصب پکیج tar.gz dataclass-persistence-0.2.1:
pip install dataclass-persistence-0.2.1.tar.gz