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

Most of the writing of this library was assisted by AI (OpenAI Codex). The code was iteratively refined and tested 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.3.tar.gz (23.3 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.3-cp314-cp314-musllinux_1_2_x86_64.whl (54.8 kB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

fastipc-0.1.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (55.4 kB view details)

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

fastipc-0.1.3-cp313-cp313-musllinux_1_2_x86_64.whl (54.8 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

fastipc-0.1.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (55.5 kB view details)

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

fastipc-0.1.3-cp312-cp312-musllinux_1_2_x86_64.whl (54.8 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

fastipc-0.1.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (55.4 kB view details)

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

fastipc-0.1.3-cp311-cp311-musllinux_1_2_x86_64.whl (55.6 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

fastipc-0.1.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (56.2 kB view details)

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

fastipc-0.1.3-cp310-cp310-musllinux_1_2_x86_64.whl (54.7 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

fastipc-0.1.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (55.3 kB view details)

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

fastipc-0.1.3-cp39-cp39-musllinux_1_2_x86_64.whl (54.2 kB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

fastipc-0.1.3-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (54.8 kB view details)

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

File details

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

File metadata

  • Download URL: fastipc-0.1.3.tar.gz
  • Upload date:
  • Size: 23.3 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.3.tar.gz
Algorithm Hash digest
SHA256 4c91fdaa7ea8197fc330b17c6db8fa5d0180b9050ff20205844e08615590d5db
MD5 9f1580c54c6d8a851ff00c9f1ec01d8e
BLAKE2b-256 c1f9510adc2ab69d0e8d824726972823da74d4124e59f0b3a0fd1b3a1de776d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.3.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.3-cp314-cp314-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.3-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 99ec07abb2836e5555392c8022c48e6633ace3791a302c9559f42447957b1383
MD5 72c01ecb429c81c56e06213a4ac3f7ef
BLAKE2b-256 66be162ce2a2ce9ab4160415bcc59b94ce4d1318615a6127717c65cbe8e6795c

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.3-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.3-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.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ccb5f771fefa0f2537492f379461019b9aa5c0a3dc1ff4349116f39cdad76ca7
MD5 c5dfa2d27e78c931ffa8f85a3e5fa036
BLAKE2b-256 ab01709a4ecaa69f47946a8a31481c166312c259dbb6d95b3e93a58d809dad66

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.3-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.3-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.3-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 17ba194054595789649305827de2ade0f761defabc736d6739673a7f34d3bdd2
MD5 8084cb5484aefc936a95b29d854f4b2a
BLAKE2b-256 7f80bb3f2400274b7307cedf36b607addc34d897dc682fa34fda62501705a3c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.3-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.3-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.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7c9be895fdf3f0a182b47daf0351326b26c4866d180b7cfaca19dc6ba45f2ef0
MD5 cc5bd1306a2fa09087a18189e802c778
BLAKE2b-256 f61660174ad651a30e6de13e8039a469654d15d3cea77e7cf3dd9b6c8caaf033

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.3-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.3-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.3-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8cb57a59d58521aa3667aca7023868c7d245b59785e46624aa591c4bd5a6d7bf
MD5 5729d3984e4f108b19544fe88e69ac66
BLAKE2b-256 e63bdb50d4d45031548fe40d2a89dbc6bce12de83e8f381438abb8061c73a748

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.3-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.3-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.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b62f9cf0f697fda78cbd911bad6898a8f64f8d849e6909ca2eb389245ab8f7d6
MD5 cb6c73595a35bc59596e0f442e7e4921
BLAKE2b-256 1eb91996e239e42844aad4ded171cb41d45e3d5ee56df82acf84f8925380525f

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.3-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.3-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.3-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 61897c0ec88aa32d12c8d9bbdd66720d8cfdbad1ffd701906c74facf8a83e51a
MD5 9ea6a5de3a26983c853b2fda2a7dddf4
BLAKE2b-256 badcb34e093964303b16528d2c518f77393b9edde501ca2c2c89a83d35abb9fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.3-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.3-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.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5460c149e4c2e4cc65d7a6cdd5d84de6875e9dc81babae2c074e6887ad483d2e
MD5 2966d250098319d26370cf3f8cadf403
BLAKE2b-256 fec0c099730279a57335785dd0aa6284b45442f40e93bfa8115109eec470b8fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.3-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.3-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.3-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0f6ffbb94b164ba3b95e368f0e5e5903f856248f5cf612ba807249d3b1cbc1cd
MD5 fec7cffb66a8ecdb7442bab25d03c9e8
BLAKE2b-256 dbe96ca17e9ec4b747e9ea204ae586ec0df9cb7a83becab31fd85479ff12e7cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.3-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.3-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.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a39442ca7c5b1c6f4b80fd2dbbe3ea09ebbeec7e3cce49ab5efc6407598157c1
MD5 de0909f3d91a6d40168dd87842ea8cb2
BLAKE2b-256 808b6c1680cc162ab259abe51827c81fc1c3797d9970e73a9dc47ce4d14e4312

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.3-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.

File details

Details for the file fastipc-0.1.3-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.3-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 aa102d99b9c8514bbc2508d6da944afb693fd82e5af46aa2a82c13d3a6102cbe
MD5 b22f74c5af12326b35e9ba549bb24b17
BLAKE2b-256 e763b71dba26f35c9e77a9dc0301f8bd01cb395c63cdd5e3d359a19ccc7537a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.3-cp39-cp39-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.3-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.3-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 01772da6c083bc474a35d36cabc72092eab2a2be9bda57a277db594ade152310
MD5 472a73b824fa27773e67b83b52e10eed
BLAKE2b-256 fab36fd7811474acd788874b3a14ac8e5c24da23effc64440f55e82f98b4480e

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.3-cp39-cp39-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