Skip to main content

A high-performance C++ serialization library with Python bindings

Project description

Rkyv

Rkyv 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)

  1. The serializer walks the Python object graph and extracts nodes (ints, strings, containers, etc.).
  2. 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.
  3. The whole representation (JSON) is compressed with Zstd for compact transport.
  4. 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 the pyserpy/ 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 in pyserpy/.
  • A CMakeLists.txt is provided in cpp/ — the setup.py in the repository root includes a CMake-backed build helper that tries to detect and use a vcpkg toolchain when available.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rkyv-1.0.1-cp313-cp313-win_amd64.whl (5.7 MB view details)

Uploaded CPython 3.13Windows x86-64

File details

Details for the file rkyv-1.0.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: rkyv-1.0.1-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

Hashes for rkyv-1.0.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d107881552298ca87e9317954d09ad952e285781349d600ce350274967308e99
MD5 03f372220d967a5d644600a7bd41f71e
BLAKE2b-256 644d500fb5179a0c5b118be75bc2790ee36bf74dcab5d017a9c85b06e67db64d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page