Skip to main content

License: MIT PyPI package version

⚠️⚠️

Shared is an experimental data exchange and persistence solution based on human-readable files. It serves as a playground to test new ideas and then create stable derivative projects. I recently built a multi-model embedded database for persisting arbitrary-sized data. The project is called Jinbase and I strongly encourage you to give it a try.

⚠️⚠️

Cover

Pyrustic Shared

Data exchange and persistence based on human-readable files

Table of contents

Overview

Shared is a Python package created to be the programmer's companion when it comes to storing unstructured application data, managing configuration files, caching data, and exchanging data with other programs.

Under the hood, Shared uses Paradict to encode a dictionary populated with strings, scalars (integer, float, decimal float, complex, booleans), date and time, null value, binary data and nested collections (list, set, and dictionary).

Note: This library does not implement any synchronization mechanisms to prevent simultaneous access to a file, which could lead to data corruption. For a safe, more robust and rich persistence solution, please consider Jinbase.

Example

from shared import Dossier, HOME
from datetime import datetime
from pathlib import Path

# load a picture
with open("/home/alex/image.png", "rb") as file:
    photo = file.read()

# create a user profile dictionary embedding the picture
now = datetime.now()
profile = {"name": "alex", "access_datetime": now, "photo": photo,
           "pi": 3.14, "books": ["Seul sur Mars", "The Fall"],
           "is_author": True, "fingerprint": None}

# create a dossier (or access an existing one)
path = Path(HOME, "my_dossier")
dossier = Dossier(path)

# save profile dictionary in the dossier
dossier.set("my_profile", profile)

# retrieve profile dictionary
profile_bis = dossier.get("my_profile")

# let's compare the two profile objects !
assert profile == profile_bis  # True ;)

Related projects

  • Jinbase: Multi-model transactional embedded database
  • LiteDBC: Lite database connector
  • KvF: The key-value file format with sections
  • Paradict: Streamable multi-format serialization with schema
  • Asyncpal: Preemptive concurrency and parallelism for sporadic workloads

Testing and contributing

Feel free to open an issue to report a bug, suggest some changes, show some useful code snippets, or discuss anything related to this project. You can also directly email me.

Setup your development environment

Following are instructions to setup your development environment

# create and activate a virtual environment
python -m venv venv
source venv/bin/activate

# clone the project then change into its directory
git clone https://github.com/pyrustic/shared.git
cd shared

# install the package locally (editable mode)
pip install -e .

# run tests
python -m tests

# deactivate the virtual environment
deactivate

Back to top

Installation

Shared is cross-platform. It is built on Ubuntu and should work on Python 3.5 or newer.

Create and activate a virtual environment

python -m venv venv
source venv/bin/activate

Install for the first time

pip install shared

Upgrade the package

pip install shared --upgrade --upgrade-strategy eager

Deactivate the virtual environment

deactivate

Back to top

About the author

Hello world, I'm Alex (😎️), a tech enthusiast and the architect of Pyrustic ! Feel free to get in touch with me !




Back to top

Metadata

Release files for shared 0.0.32

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

Source distribution (sdist)

Source distribution for shared 0.0.32
File Size Uploaded
shared-0.0.32.tar.gz 7.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for shared 0.0.32
File Interpreter ABI Platform
shared-0.0.32-py3-none-any.whl Python 3 none any Details

Total release size: 37.1 kB

Release files / shared-0.0.32.tar.gz

Download URL shared-0.0.32.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7308adc95c0dab14d0c99635cd8049d1f004cc7fef7396d3fe47323c34ec58c6
BLAKE2b-256 checksum
How to use checksums
3f39f39c2560ac971efbf437f7ffa1d82a12fa77f50b0127e6e5ec5cc8d377df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Release files / shared-0.0.32-py3-none-any.whl

Download URL shared-0.0.32-py3-none-any.whl
Size 29.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f17962c0f0fe6a23015accc7cac029e1c24c4b14578094e1f7033a7a7ef16140
BLAKE2b-256 checksum
How to use checksums
f903da58e40386d8ebcdfa3617070a95ca1deb5a5e6aa3d4e15ea2045173d5ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.0.32 This release

2 release files

0.0.31

2 release files

0.0.30

2 release files

0.0.29

2 release files

0.0.28

2 release files

0.0.27

2 release files

0.0.26

2 release files

0.0.25

2 release files

0.0.23

2 release files

0.0.18

2 release files

0.0.17

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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