Skip to main content

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 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"}
}

Metadata

Release files for dataclass-persistence 0.3.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dataclass-persistence 0.3.7
File Size Uploaded Provenance Actions
dataclass-persistence-0.3.7.tar.gz 12.6 kB Without provenance Details for dataclass-persistence-0.3.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dataclass-persistence 0.3.7
File Interpreter ABI Platform Actions
dataclass_persistence-0.3.7-py3-none-any.whl Python 3 none any Details for dataclass_persistence-0.3.7-py3-none-any.whl

Total release size: 23.2 kB

Release files / dataclass-persistence-0.3.7.tar.gz

Download URL dataclass-persistence-0.3.7.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d6eb543d439a332c1b1451e34fec3c9812b2e02f118eb5ec0d335dea2c296f92
BLAKE2b-256 checksum
How to use checksums
e745a8e7dc205c7e9c035ddb5a2ba68744a989e3fa27960654b945378d88656a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.4

Release files / dataclass_persistence-0.3.7-py3-none-any.whl

Download URL dataclass_persistence-0.3.7-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2cdc6f5b3cc0099b9e3eea9fbd8fe70d974cb78d0871c9ff5ba0471e3b9c05f
BLAKE2b-256 checksum
How to use checksums
53c6a56739b09bf6081c14c94527ba657d01f800c0613a7891121e7fce144dcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.4

Security for dataclass-persistence 0.3.7

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.7 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page