Skip to main content

Python containers using shared memory.

Project description

sharedbox

[!WARNING] This project is a work in progress; be patient or feel free to contribute.

Python inter-process shared containers leveraging boost::interprocess.

Installation

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

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

Quick Start

import multiprocessing as mp
from sharedbox import SharedDict

# Use in child processes
def worker(segment_name):
    d = SharedDict(segment_name, create=False)  # Connect to existing
    d["worker_data"] = "Hello from worker!"
    d.close()  # Close in child process

if __name__ == "__main__":
    # Create a shared dictionary
    d = SharedDict("my_segment", create=True, size=10*1024*1024)
    d["hello"] = "world"
    d["data"] = [1, 2, 3, 4, 5]

    # Start worker
    p = mp.Process(target=worker, args=("my_segment",))
    p.start()
    p.join()

    print(d["worker_data"])  # "Hello from worker!"
    d.close() # Close in the main process
    d.unlink()  # Unlink (free resources)

Initialization with Data

You can initialize SharedDict with existing data for convenient setup:

import numpy as np
from sharedbox import SharedDict

# Initialize with mixed data types
config_data = {
    "app_name": "MyApp",
    "version": "1.0",
    "max_users": 1000,
    "features": ["auth", "logging"],
    "model_weights": np.array([0.1, 0.3, 0.6])
}

# Create SharedDict with initial data
shared_config = SharedDict("config", config_data, create=True)

# Data is immediately available
print(shared_config["app_name"])  # "MyApp"
print(shared_config["model_weights"])  # numpy array

# when a child process doesn't need the memory anymore call "close"
shared_config.close()

# the main process is in charge of cleaning up; call "unlink" to do so,
# similarly to a regular python SharedMemory object;
# make sure that the main process calls "close" before as well
shared_config.unlink()

Limitations

  • Nested dictionaries are "currently" unsupported
  • Project is quite unstable, might not provide great performance boost at this time
  • macOS unsupported

Examples

The examples/ folder contains some code examples on how to use the package.

Building locally

Requirements

  • git
  • uv
  • Python >= 3.10
  • vcpkg
  • cython>=3.1
  • A C++17 compatible compiler

First install and boostrap vcpkg somewhere in your system.

# for Windows it is reccomended to install it in C:\
cd C:\

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

Don't forget to add it to your PATH.

Also, add an environment variable pointing to the root of vcpkg:

set "VCPKG_ROOT=C:\path\to\vcpkg"

Clone this repository, then install boost::interprocess:

vcpkg install boost-interprocess

Finally, through uv, install the package in a virtual environment:

uv venv --python 3.10
uv pip install -e .[dev]

License

Licensed under Apache 2.0

Project details


Download files

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

Source Distribution

sharedbox-0.1.0.tar.gz (71.7 kB view details)

Uploaded Source

Built Distributions

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

sharedbox-0.1.0-cp313-cp313-win_amd64.whl (157.5 kB view details)

Uploaded CPython 3.13Windows x86-64

sharedbox-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

sharedbox-0.1.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

sharedbox-0.1.0-cp312-cp312-win_amd64.whl (157.8 kB view details)

Uploaded CPython 3.12Windows x86-64

sharedbox-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

sharedbox-0.1.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

sharedbox-0.1.0-cp311-cp311-win_amd64.whl (158.3 kB view details)

Uploaded CPython 3.11Windows x86-64

sharedbox-0.1.0-cp311-cp311-musllinux_1_2_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

sharedbox-0.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

sharedbox-0.1.0-cp310-cp310-win_amd64.whl (158.1 kB view details)

Uploaded CPython 3.10Windows x86-64

sharedbox-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

sharedbox-0.1.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file sharedbox-0.1.0.tar.gz.

File metadata

  • Download URL: sharedbox-0.1.0.tar.gz
  • Upload date:
  • Size: 71.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedbox-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cd381b3074494b2a1ea90738cfbc6fe7c23ee3d446529950b1a52cfc81477899
MD5 dc3610ce2550e8726a848df4901790fd
BLAKE2b-256 6300840f7170666b3c5bebf80f2c8fd5447b29780e6188ded7e6907978dd4912

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedbox-0.1.0.tar.gz:

Publisher: ci.yaml on jacopoabramo/sharedbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedbox-0.1.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: sharedbox-0.1.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 157.5 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedbox-0.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7de76d870441e75643eee584117b56c94e7205e0a0a423741c9ae8376951daa0
MD5 b9b2972fce7ca83a10920320e517bc08
BLAKE2b-256 ca073a3f08ca884082a6b7ee9cfb5afb69d5fac4c3b2462056fb81f73df04aa7

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedbox-0.1.0-cp313-cp313-win_amd64.whl:

Publisher: ci.yaml on jacopoabramo/sharedbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedbox-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for sharedbox-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2a8505e921b24407c7e0d5ce9e96d6ee33dd3750fee73200e881be477dfd9927
MD5 dd8da82f2d3d64946fbf0ff8f8537f97
BLAKE2b-256 36505787e29a7d6ee858fef7882f468d139514ae1c8ce65c526cb1f1170ccaa6

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedbox-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl:

Publisher: ci.yaml on jacopoabramo/sharedbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedbox-0.1.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for sharedbox-0.1.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5f5a81c31c9a3553bf3508d42515f2f8b1cd82f13abb9a723abfc54dc4fc7d2c
MD5 8176de5bbdb5eb010c95bc9a2affc058
BLAKE2b-256 e0b795ee5a9b5e5621779185ae0cfbda0ffcddc9146ba84facc36cb8bd7ae3c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedbox-0.1.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: ci.yaml on jacopoabramo/sharedbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedbox-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: sharedbox-0.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 157.8 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedbox-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f6fac6ca31a254914840803b83dcbaa2de6cfea6ca909e67b41a12675b141baa
MD5 ad91f16e0cd023c6da790abf1ea18e9d
BLAKE2b-256 c513978e9e3066ef5630a717350ba803f2d6f24092ab4890165284d3217d4f47

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedbox-0.1.0-cp312-cp312-win_amd64.whl:

Publisher: ci.yaml on jacopoabramo/sharedbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedbox-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for sharedbox-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 70bb7be3348170fdcd5a0c556bab974d19dcaabebd337d04128b45eb2c0b7742
MD5 bbda89385b59adb1e716ce840d9f35ca
BLAKE2b-256 74f0483c9d0da9c24206b387c5e536c2bcf3f3b93853d2d95af1a3466cba9591

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedbox-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl:

Publisher: ci.yaml on jacopoabramo/sharedbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedbox-0.1.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for sharedbox-0.1.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 164603728d886256bc67da31fa06c1525fd8337567152192bbce67f7f6348c0d
MD5 ea946c43e691837db7eb6fbfe7f2538f
BLAKE2b-256 1777ca8d8af0af6a4a0d56e6040718c372219e89ed7d2acca417885982dbd99b

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedbox-0.1.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: ci.yaml on jacopoabramo/sharedbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedbox-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: sharedbox-0.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 158.3 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedbox-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 bedc01d15d9410d322faa4e9c6f50ee8cc3e8559a6e02e436630fd50c8706849
MD5 e10ba6239dfa841ff51fb17d6361047b
BLAKE2b-256 a229c95cb34597d8278c8a3495f45c72f5b5131c6dc6cd361ef38655fa83ec3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedbox-0.1.0-cp311-cp311-win_amd64.whl:

Publisher: ci.yaml on jacopoabramo/sharedbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedbox-0.1.0-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for sharedbox-0.1.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 54927c15b29991a7358559f9103dd4b7bf08c472de924ea98fc0b1d4cb64ea0f
MD5 e2f0fd28cb1e318fada747ea02436815
BLAKE2b-256 2d9fe70b3c4c28974e6f043439c2463527cfab75421cdedbbc400ce94d369cf4

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedbox-0.1.0-cp311-cp311-musllinux_1_2_x86_64.whl:

Publisher: ci.yaml on jacopoabramo/sharedbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedbox-0.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for sharedbox-0.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fa85bf0d953f1df2047d1c1efac2055652ad0fca61852a891fa067cbf70054f2
MD5 20ca3cfc6eac9cddcc3e0f1411048a83
BLAKE2b-256 54bf35e71139bec47d654bb48e81b0dfb31b051f2746753ecb2a18732269d791

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedbox-0.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: ci.yaml on jacopoabramo/sharedbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedbox-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: sharedbox-0.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 158.1 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedbox-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 1d1b0c3d13975d8bf9c56592fe0c3c107a9806b4ad132ab49b743d1debf982e6
MD5 cd51b974483401ffa01a0e5691c76037
BLAKE2b-256 9dbc2cc350d6e9d2cc7e257115ac99ad35410f54d100faa36f6194dde0c8344c

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedbox-0.1.0-cp310-cp310-win_amd64.whl:

Publisher: ci.yaml on jacopoabramo/sharedbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedbox-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for sharedbox-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fb19dcdda3e86d81d321311f3bd719b80794aff27a6c08ebf2bf4fbc7c34f331
MD5 17baca81edfe41d298d66964db02d971
BLAKE2b-256 b6be3ac09becf00a711202719cd4febf3944191408eaf0e900595c5c5ad3186f

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedbox-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl:

Publisher: ci.yaml on jacopoabramo/sharedbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedbox-0.1.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for sharedbox-0.1.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6d45ef26eeb05f1870f770c3b0bd7136850e4156621cf78c945477aebc00ccaa
MD5 6eae39872dea02df3e7c1a4a9cfb8def
BLAKE2b-256 001917a3e0f7ad3c01f3fa3cb7bf5a534339183a95e39a47e6ee39365c63cebb

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedbox-0.1.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: ci.yaml on jacopoabramo/sharedbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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