A high-performance C++ serialization library with Python bindings
Project description
Serpy
Serpy is a thin Python wrapper around the high-performance C++ "pyser" serialization library. It exposes a compact Python API (dumps/loads/dump/load) and is intended to provide efficient binary serialization of Python objects with chunking and per-chunk SHA256 checksums.
Features and advantages
- Fast native implementation in C++ with Python bindings.
- Chunked representation: large objects are split into chunks to reduce peak memory usage and allow partial processing in future extensions.
- Per-chunk SHA256 checksums provide corruption detection during deserialize.
- Optional file-based helpers to write/read serialized data.
- Designed to be packaged as a binary wheel that contains the compiled extension and its runtime dependencies (via vcpkg on Windows).
How it works (high level)
- The serializer walks the Python object graph and extracts nodes (ints, strings, containers, etc.).
- Large payload bytes are split into fixed-size chunks. Each chunk is base64-encoded in the JSON structure and carries a SHA256 hash of the raw bytes.
- The whole representation (JSON) is compressed with Zstd for compact transport.
- On deserialize, the JSON is decompressed, each chunk is base64-decoded and its SHA256 re-computed and compared with the stored value. If all checks pass, the Python objects are reconstructed.
Quick start
You can now install PySer directly using the setup.py script:
# Clone the repository
git clone https://github.com/rand0mdevel0per/pyser.git
cd pyser
# Install the package directly
./setup.py install
Alternatively, you can use the provided installation scripts:
For Windows (PowerShell):
# Download and run the PowerShell installation script
curl -o install.ps1 https://raw.githubusercontent.com/rand0mdevel0per/pyser/main/install.ps1
.\install.ps1
For Linux/Mac (Bash):
# Download and run the Bash installation script
curl -o install.sh https://raw.githubusercontent.com/rand0mdevel0per/pyser/main/install.sh
chmod +x install.sh
./install.sh
You can also install the package using pip after cloning:
git clone https://github.com/rand0mdevel0per/pyser.git
cd pyser
python -m pip install .
Basic usage
from pyserpy import dumps, loads, dump, load
obj = {"a": [1, 2, 3]}
data = dumps(obj) # returns bytes
obj2 = loads(data)
# file based
dump(obj, "data.bin")
obj3 = load("data.bin")
Packaging notes
- This package bundles a compiled extension. The recommended way to produce a distributable wheel
is to compile the native extension for the target platform and then build a wheel (e.g. using
python -m build) including the compiled shared library inside thepyserpy/package directory. - On Windows, use vcpkg to install consistent versions of OpenSSL and Zstd used by the project.
Developer notes
- The repository contains C++ sources in the
cpp/directory and the Python wrapper inpyserpy/. - A CMakeLists.txt is provided in
cpp/— thesetup.pyin the repository root includes a CMake-backed build helper that tries to detect and use a vcpkg toolchain when available.
License
MIT
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 rkyv-1.0.0.tar.gz.
File metadata
- Download URL: rkyv-1.0.0.tar.gz
- Upload date:
- Size: 63.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54491cc6d8ee3ddc161498a478ed694c656b24d8593bfa43360b67fcf323569d
|
|
| MD5 |
1b76a8e3e23778ce356f7f4df1283340
|
|
| BLAKE2b-256 |
cc32cfd991440d34a2b290c6e0ccddce1c06675772fadf09c832f5d9b0582a85
|
File details
Details for the file rkyv-1.0.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: rkyv-1.0.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 5.7 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e95ec46e781fba763348bcc455a88fe0c34e4d1635b7458db31c75d3e07b6da9
|
|
| MD5 |
74c2ef8854d4dd86ea702277c1ca15ee
|
|
| BLAKE2b-256 |
0370c60b570b49ec28ed4e609493b64fd628b78ed8c544cd3ffaca3e045f6f92
|