Skip to main content

Linux futex-based primitives (C extension)

Project description

fastipc — Fast Machine-level Sync for Python

Fast IPC synchronization primitives in C11/CPython extension, with:

  • Explicit acquire/release semantics and a focus on latency and throughput.
  • Primitives operate on caller-supplied buffer (thus machine-level)
  • Comes with Named helpers for easier usage out of the box.

Status: Linux-only (futex backed). Python >= 3.9. Targets x86_64 and other Linux archs.

Installation

pip install fastipc

Why fastipc

  • Minimal hot-path: pure atomics for uncontended operations; futex syscall only on contention.
  • Buffer-backed: pass a 4-byte aligned memoryview to operate in threads or across processes.
  • Strict memory ordering: acquire/release semantics on loads, stores, and CAS.
  • Simple helpers: NamedEvent, NamedMutex, NamedSemaphore for quick cross‑process usage.

Core Primitives

  • FutexWord: raw futex wait/wake on a 32‑bit word.
  • AtomicU32 / AtomicU64: atomic load/store/CAS on a shared word.
  • Mutex: futex‑based mutex with spin‑then‑sleep contention path.
  • Semaphore: futex‑based counting semaphore with exact‑delivery wakeups.

Cross‑Process: Buffer‑backed

from multiprocessing import shared_memory
from fastipc import FutexWord, Mutex, Semaphore

shm = shared_memory.SharedMemory(create=True, size=4)
try:
    fw = FutexWord(shm.buf, shared=True)
    # Other processes attach via SharedMemory(name=...) and reuse the same buffer
finally:
    shm.close(); shm.unlink()

# Mutex and Semaphore require 64 bytes
shm = shared_memory.SharedMemory(create=True, size=64)
try:
    mtx = Mutex(shm.buf)
    with mtx:
        ...  # critical section
finally:
    shm.close(); shm.unlink()

Cross‑Process: Named Helpers

These helpers use a shared‐memory word under the hood, plus a small PID‑tracking directory for safe cleanup.

from fastipc import NamedEvent, NamedMutex, NamedSemaphore

# Event
evt = NamedEvent("job_ready")
evt.set()          # wake all waiters
evt.clear()        # reset
evt.wait(1_000_000_000)  # wait with 1s timeout (ns)

# Mutex
mtx = NamedMutex("global_lock")
with mtx:
    ...

# Semaphore
sem = NamedSemaphore("queue_slots", initial=0)
sem.post(3)
sem.wait()         # blocks if no tokens

Notes:

  • PID tracking directory defaults to /dev/shm/fastipc. In restricted environments, set FASTIPC_PID_DIR=/tmp/fastipc (or any writable dir).

Performance Notes

  • Uncontended paths use only atomics (no syscalls).
  • Under contention, primitives spin briefly (adaptive) then futex sleep to minimize wake storms and context switches.
  • Semaphore.post(n) atomically adds n tokens and only wakes waiters when the count transitions from 0; the wake hint is capped at min(n, INT_MAX) to stay portable.
  • Expect on-par or better performance than posix_ipc and multiprocessing alternatives in most scenarios.

Platform Support

  • Linux only (uses linux/futex.h).
  • Wheels target manylinux/musllinux for x86_64 and aarch64. Some arches may require -latomic (handled during build).

AI Code Generation

Writing of this library was assisted by AI (OpenAI Codex). The code was iteratively refined, checked, and tested manually to ensure correctness and performance.

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

fastipc-0.1.5.tar.gz (30.1 kB view details)

Uploaded Source

Built Distributions

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

fastipc-0.1.5-cp314-cp314-musllinux_1_2_x86_64.whl (62.8 kB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

fastipc-0.1.5-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (63.5 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

fastipc-0.1.5-cp313-cp313-musllinux_1_2_x86_64.whl (62.8 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

fastipc-0.1.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (63.6 kB view details)

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

fastipc-0.1.5-cp312-cp312-musllinux_1_2_x86_64.whl (62.8 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

fastipc-0.1.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (63.5 kB view details)

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

fastipc-0.1.5-cp311-cp311-musllinux_1_2_x86_64.whl (63.8 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

fastipc-0.1.5-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (64.4 kB view details)

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

fastipc-0.1.5-cp310-cp310-musllinux_1_2_x86_64.whl (62.9 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

fastipc-0.1.5-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (63.5 kB view details)

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

File details

Details for the file fastipc-0.1.5.tar.gz.

File metadata

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

File hashes

Hashes for fastipc-0.1.5.tar.gz
Algorithm Hash digest
SHA256 e4e0988865db103826de084df9f1ca3022487c2a7683a81d3346fa4fe0cc6b6f
MD5 e359e76bc186540ed25f564e9bc427c1
BLAKE2b-256 c08e75b1b662f627afd797425f4dc9a434f87633f47f4d1904ef0ca33966ebfc

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.5.tar.gz:

Publisher: python-publish.yml on BlindedShooter/pyfastipc

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

File details

Details for the file fastipc-0.1.5-cp314-cp314-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.5-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b64567291f52705b6a26296b179f0817665a25ad7829db596f22011a3f9d24ac
MD5 03b40234bc822b29b1b7360a4c5b3d30
BLAKE2b-256 0e3da90e93a39b513d86ae0d32dbae852e435522f9946ed8d17d910b693ec07e

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.5-cp314-cp314-musllinux_1_2_x86_64.whl:

Publisher: python-publish.yml on BlindedShooter/pyfastipc

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

File details

Details for the file fastipc-0.1.5-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.5-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b457e6b0bdb49017844bac5c76660e645c2650f556a032ac3c191bdba23da727
MD5 f955bdeda933b0066dab919dc8aaeca5
BLAKE2b-256 743fe62c3d5b2437495df631e3dcb52936f1350e87ec1ecb8ee35d4372840fcf

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.5-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on BlindedShooter/pyfastipc

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

File details

Details for the file fastipc-0.1.5-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.5-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 af18f4c5f747cbdefb8c75390435095f03e9c971940906be26f47da9cdcb7b56
MD5 b4aaafdbce9b994759679f26c70906df
BLAKE2b-256 7894454e965b8e73fd12e56d2028e4fa593608392e0c3f369ceba1caf7ef450f

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.5-cp313-cp313-musllinux_1_2_x86_64.whl:

Publisher: python-publish.yml on BlindedShooter/pyfastipc

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

File details

Details for the file fastipc-0.1.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d2fa49506ae15945a9e8446d55a0ab6d2e63216e7db9ddc23321bd22c8773187
MD5 d2865d5986e420782221363027d5017c
BLAKE2b-256 fcf71a42de8984b22ce9804ec0bd5172ed2e762bcdfd8d12710640e3a117f9fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on BlindedShooter/pyfastipc

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

File details

Details for the file fastipc-0.1.5-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.5-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 355e1be208f7ef2e2ef46daed7538346a7a595473a6a9fd56ca2f24ed95d1e86
MD5 16920081a7985cff90c18f864f5d4b07
BLAKE2b-256 c94238f76e445060680d18fa3f61b9e2628df76fed264e4c08f61445975e8440

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.5-cp312-cp312-musllinux_1_2_x86_64.whl:

Publisher: python-publish.yml on BlindedShooter/pyfastipc

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

File details

Details for the file fastipc-0.1.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ee51ce864e83f887a39263d18430248f48eabadb6e083213325362493182dc24
MD5 d88cba3cbcd9129065851c79ee661e94
BLAKE2b-256 f398f279825642642825920ea3de0028da2f70047dae499ce83e3f3efcb9e17b

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on BlindedShooter/pyfastipc

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

File details

Details for the file fastipc-0.1.5-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.5-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8292e90c2273b2c2acff4e1ce38cfd511e6559b4b09031e2931e96268ac66682
MD5 227d30bc2712fe4a5444d3131c895845
BLAKE2b-256 d6571ec9519e74b999725a026fa0dd7b726eda3dff6195fdc1cb1ba2a798f4de

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.5-cp311-cp311-musllinux_1_2_x86_64.whl:

Publisher: python-publish.yml on BlindedShooter/pyfastipc

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

File details

Details for the file fastipc-0.1.5-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.5-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3ed7c577b6931eaa30765924f33379eddadd73923bfdb947e58a6dcfb75ce1d2
MD5 2ebf4d15bd15a89376ad91d461d65571
BLAKE2b-256 df2533317603ef49130a975d3993c22d0910b7e9af74f774ce40552af2e71f04

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.5-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on BlindedShooter/pyfastipc

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

File details

Details for the file fastipc-0.1.5-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.5-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b7569f4156b90b8bf4e1e826629441a96d79eb4e28e990ebfeb866bb197eec78
MD5 408493a6a2af902921e6adfee4c8c55d
BLAKE2b-256 51aa8ef230f8f8aa7e6a8b940494d814014459f71fe82e3d23c6cfa6a4984b9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.5-cp310-cp310-musllinux_1_2_x86_64.whl:

Publisher: python-publish.yml on BlindedShooter/pyfastipc

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

File details

Details for the file fastipc-0.1.5-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.5-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8eaed6599a1c99261542af4044427872d2ee33edfd2c8a99d53881889675c1ab
MD5 9a8a2c76d642d9551b18b692bfdda9e5
BLAKE2b-256 1ac41833de08aa5dddee7d1169fdda9b6e871ac258ced3fb2e99bfe57dc5fc73

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.5-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on BlindedShooter/pyfastipc

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