Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

sharedbox

PyPI CI CodSpeed Ruff clang-format Checked with mypy

sharedbox keeps records in shared memory. Each box is one named segment, made with the boost::interprocess library, and every process that opens it reads and writes the same fields.

Installation

It is recommended to install sharedbox in a virtual environment; for example using uv:

uv venv --python 3.11
.venv\Scripts\activate
uv pip install sharedbox

Quick start

import multiprocessing as mp
from typing import Annotated

from sharedbox import Capacity, SharedBox


class Motor(SharedBox):
    position: int
    enabled: bool
    label: Annotated[str, Capacity(32)]


def worker() -> None:
    motor = Motor.attach()          # finds the box by its class
    motor.position = 10
    motor.close()


if __name__ == "__main__":
    with Motor(1, False, "x-axis") as motor:
        motor.events.position.connect(lambda new, old: print(old, "->", new))
        child = mp.Process(target=worker)
        child.start()
        child.join()                      # prints: 1 -> 10
    Motor.unlink()

Reacting to changes

box.events is a psygnal SignalGroup: box.events.position.connect(cb) calls cb(new, old) when any thread or process changes position, and box.events.connect(cb) reports every field. Callbacks run on a background thread; pass thread="main" to connect and call psygnal.emit_queued() from your event loop to run them on the main thread.

To wait instead of reacting, box.watch(field) iterates over new values with for or async for, skipping values written while the consumer was busy.

Lifetime

As with multiprocessing.shared_memory.SharedMemory: close() (or leaving the with block) detaches one box and never destroys the data, and unlink() removes the segment's name. Call Motor.unlink() once, usually from the process that created the box. On Linux a segment that is never unlinked stays in /dev/shm until reboot, and the next Motor(...) then raises SegmentExistsError; on Windows the OS frees it when the last box closes and unlink() does nothing. sharedbox does not unlink anything at exit, like SharedMemory(track=False).

Limitations

  • Field types: bool, int (64-bit), float, and str or bytes with a Capacity in bytes. Nested boxes and arrays are not supported yet.
  • Writers take one lock per box. Readers never block writers.
  • macOS is not supported.

The full API is described in docs/api.md.

Wheels

Each platform gets one wheel for CPython 3.11, one abi3 wheel for CPython 3.12 and newer, and one for free-threaded CPython 3.14. Wheels are built for Windows x64 and Linux x86_64 (glibc and musl).

Building locally

Requirements

  • git
  • uv
  • Python >= 3.11
  • vcpkg
  • CMake >= 3.30
  • A C++17 compatible compiler (MSVC on Windows, GCC on Linux)

Install and configure vcpkg

Install and bootstrap vcpkg somewhere on your system.

Windows

cd C:\
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
bootstrap-vcpkg.bat

# Set the VCPKG_ROOT environment variable (permanently)
setx VCPKG_ROOT "C:\vcpkg"

Linux

git clone https://github.com/microsoft/vcpkg.git ~/vcpkg
~/vcpkg/bootstrap-vcpkg.sh
export VCPKG_ROOT=~/vcpkg   # add this line to your shell profile

Boost is listed in vcpkg.json and installed by CMake on the first build.

Build the package

git clone https://github.com/jacopoabramo/sharedbox.git
cd sharedbox
uv sync --dev

uv sync --dev creates .venv, builds the extension and installs it.

Development setup

After uv sync --dev, run this once to point VS Code's C/C++ extension at the CPython, nanobind and Boost headers the build uses:

uv run python scripts/vscode_setup.py

Run it again after changing the Python version or deleting build/.

Run uv run prek install once to lint and format each commit; uv run tox -e lint runs the same checks on demand.

Running tests

uv run pytest               # current interpreter
uv run tox                  # every supported Python version, plus mypy
uv run tox -e py314t        # one version

Running benchmarks

The benchmarks extra installs a benchbox command that measures sharedbox on your own machine:

pip install "sharedbox[benchmarks]"

benchbox ops               # single operations, against the standard library
benchbox ops --fast --filter "read*" --json ops.json
benchbox roundtrip         # change notification between two processes
benchbox size dist/*.whl   # wheel and extension module size
benchbox all --out results # all of the above, plus results/summary.md

ops runs on pyperf; arguments after -- are passed to it unchanged. all writes each command's JSON output and a Markdown summary with the OS, CPU, Python version and build, and the sharedbox version. It measures wheel sizes only when it finds wheels in dist/ or wheelhouse/, and then measures every wheel there, older builds included. python -m sharedbox.benchmarks runs the same command.

In a checkout, uv sync installs the benchmarks dependency group, which has the same packages as the extra, so uv run benchbox works there too. The pytest benchmarks are separate and live only in the repository:

uv run pytest benchmarks --codspeed

CI runs them on CodSpeed for every push and pull request to main.

License

Licensed under Apache 2.0

sharedbox is built using the Boost C++ library, which is licensed under the Boost Software License.

Release files for sharedbox 0.3.0rc0

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

Source distribution (sdist)

Source distribution for sharedbox 0.3.0rc0
File Size Uploaded
sharedbox-0.3.0rc0.tar.gz 113.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for sharedbox 0.3.0rc0
File
sharedbox-0.3.0rc0-cp314-cp314t-win_amd64.whl CPython 3.14 CPython 3.14 free-threading Windows x86-64 Details
sharedbox-0.3.0rc0-cp314-cp314t-musllinux_1_2_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ x86-64 Details
sharedbox-0.3.0rc0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
sharedbox-0.3.0rc0-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details
sharedbox-0.3.0rc0-cp312-abi3-musllinux_1_2_x86_64.whl CPython 3.12 abi3 Linux musl 1.2+ x86-64 Details
sharedbox-0.3.0rc0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
sharedbox-0.3.0rc0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
sharedbox-0.3.0rc0-cp311-cp311-musllinux_1_2_x86_64.whl CPython 3.11 CPython 3.11 Linux musl 1.2+ x86-64 Details
sharedbox-0.3.0rc0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details

Total release size: 2.8 MB

Release files / sharedbox-0.3.0rc0.tar.gz

Download URL sharedbox-0.3.0rc0.tar.gz
Size 113.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d294fcf6e506c186dd989c1cf1a6cdf50f120bb7677ceae11e4797029d76b8d8
BLAKE2b-256 checksum
How to use checksums
53d7e13d48d994033aa2b52a00a93ff0edf385ef73c2cbe7c97f9b012037fdba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / sharedbox-0.3.0rc0-cp314-cp314t-win_amd64.whl

Download URL sharedbox-0.3.0rc0-cp314-cp314t-win_amd64.whl
Size 162.8 kB
Tags CPython 3.14 CPython 3.14 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
30ce1872b4d66d15493b01da65a4129807fa07c16d93ec7ba0412f1afd3370b2
BLAKE2b-256 checksum
How to use checksums
8f88418c1b9a8a501ef35c3dbda3bf586570d7ede6713bafc3f8580c21dc57cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / sharedbox-0.3.0rc0-cp314-cp314t-musllinux_1_2_x86_64.whl

Download URL sharedbox-0.3.0rc0-cp314-cp314t-musllinux_1_2_x86_64.whl
Size 611.1 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
ddfb282e7f2d544caddc835205d78c5f70d2b994a6db30f00732dd7c242bdcc5
BLAKE2b-256 checksum
How to use checksums
a675aebb70ca60d5e4a821747009a40ff21f8e5fa73a375797a4d62fd6b8e5a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / sharedbox-0.3.0rc0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL sharedbox-0.3.0rc0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 144.2 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
2b99c2c23b214b694b488874fb95c5fe3b25be5a32baa8f8ec7914f5f24be69c
BLAKE2b-256 checksum
How to use checksums
9161c5aeca0e0c4e490b413e734420abe81a80775e87fbe72fed460001ea28fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / sharedbox-0.3.0rc0-cp312-abi3-win_amd64.whl

Download URL sharedbox-0.3.0rc0-cp312-abi3-win_amd64.whl
Size 155.8 kB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
b85e061477ec9c95ed5d51d670150daabb544dc10728d4d525713c92a2b8fd9b
BLAKE2b-256 checksum
How to use checksums
9e1b058d13b797f7b28f0bb10b851ccf12d1b499a0ff180a5258369fcfabb522
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / sharedbox-0.3.0rc0-cp312-abi3-musllinux_1_2_x86_64.whl

Download URL sharedbox-0.3.0rc0-cp312-abi3-musllinux_1_2_x86_64.whl
Size 604.2 kB
Tags CPython 3.12 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
e1dff6b41e745bc2efdd5afac93b73892cf4dc8d4404a18d162862b215b4f3d8
BLAKE2b-256 checksum
How to use checksums
6b3e0f0a5dec44699286788e1795d3a5aeeb7da79eb3810603564a6de2c50dba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / sharedbox-0.3.0rc0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL sharedbox-0.3.0rc0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 140.3 kB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
d58bb2ebbe74069c2d029934f7d5d2cccb702a76244327008620d06637984e24
BLAKE2b-256 checksum
How to use checksums
2e90b7fe6b8358c88871e0461a5064a8b6877709686b563e4124dd6cf43a77ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / sharedbox-0.3.0rc0-cp311-cp311-win_amd64.whl

Download URL sharedbox-0.3.0rc0-cp311-cp311-win_amd64.whl
Size 156.4 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
038c887401885f0f6dc943c1cf883401d06bb2240f34bc11e73db3c222c1cf27
BLAKE2b-256 checksum
How to use checksums
38c51edc1a969a213d3f89fa317ad85baaa22c030920124bb1c489c2fbe17099
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / sharedbox-0.3.0rc0-cp311-cp311-musllinux_1_2_x86_64.whl

Download URL sharedbox-0.3.0rc0-cp311-cp311-musllinux_1_2_x86_64.whl
Size 609.7 kB
Tags CPython 3.11 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
478ef11978476204b21f8907f85dd8a3eb4ccc93a82eb787c2d101a84855e39a
BLAKE2b-256 checksum
How to use checksums
316b62aa001e31092f7968339ecc68afea86076eb348715a8f79d40550e8d832
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / sharedbox-0.3.0rc0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL sharedbox-0.3.0rc0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 144.1 kB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
7a3f191e1d7fe2ea52c9c15bbcb2109792f2ab14c4f1e05d007716d2ff560d64
BLAKE2b-256 checksum
How to use checksums
ce59255e9bc16b4ba70f06929c0b2730e44c0c61c4173cbf5770d3c70af85a22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0rc0 This release

10 release files

0.2.3

3 release files

0.2.2

3 release files

0.2.1

3 release files

0.2.0

3 release files

0.1.0

13 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