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.2.tar.gz (23.0 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.2-cp313-cp313-musllinux_1_2_x86_64.whl (54.5 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

fastipc-0.1.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (55.1 kB view details)

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

fastipc-0.1.2-cp312-cp312-musllinux_1_2_x86_64.whl (54.4 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

fastipc-0.1.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (55.1 kB view details)

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

fastipc-0.1.2-cp311-cp311-musllinux_1_2_x86_64.whl (55.2 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

fastipc-0.1.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (55.9 kB view details)

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

fastipc-0.1.2-cp310-cp310-musllinux_1_2_x86_64.whl (54.3 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

fastipc-0.1.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (55.0 kB view details)

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

fastipc-0.1.2-cp39-cp39-musllinux_1_2_x86_64.whl (53.9 kB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

fastipc-0.1.2-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (54.5 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.2.tar.gz.

File metadata

  • Download URL: fastipc-0.1.2.tar.gz
  • Upload date:
  • Size: 23.0 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.2.tar.gz
Algorithm Hash digest
SHA256 5d4b400ff928364a91891895f01b830f5f3c9b603009b3fc6de2ba166d16ef27
MD5 a680abab8aee70633b4a92cb2552945f
BLAKE2b-256 3f6498f7a6754600a5fafaa79c88375f75cfb6119554e7c568efa36827c845f6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fastipc-0.1.2-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2d11092eb19baad68131b32def7ba68f3767db0c6aebaa7e7d1ecca1c86b0cc5
MD5 035b9583129066d1b5cb8eb3d7c39769
BLAKE2b-256 10fc1063f6f540a7268a275d74412bbe860643340d6c62e0535f220895962edf

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.2-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.2-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.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d89ee70e95f5605eb05c23d9a12857de179acc4e8f9a80a504ba7488d7fcf0c3
MD5 edf6d8788111c20b92b741fe17a9160e
BLAKE2b-256 488a47cf775abcd20c71ce7312a2d32f4918576e2cd857d2f47085fb8d5137ae

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fastipc-0.1.2-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 17709b4ff890df99dd48981b645677e4a8ef27198440a8f280e85898943d5b41
MD5 2330529411ffc64a924677ef60a3b1ec
BLAKE2b-256 d5729f94bbf7b4b82be95ec52cb5be214ef20ff15a8a70c0d6b5af8f96e52f61

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.2-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.2-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.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a2fdb13208cacdadb16152e1358dfb3f3793562d027d57c0c39add411a59b4f0
MD5 73432ec9cdbc20019928440ebc165e1d
BLAKE2b-256 cf1a7c6ed143f540ad619e0a937c3a0682dfa480cfbb21dc76cf68bdddebe6a1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fastipc-0.1.2-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 22f456acce6e823767b6f6d7c6b3cd46d4cff9f09b5b82c056687ef931c427f0
MD5 a4899ca082ceeff0b8c3cf132e4a9f88
BLAKE2b-256 d2d25dc8f81794690775c5c2fb0d1d5f4f195c22b2840528a199e6b31e28d96c

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.2-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.2-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.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e9939394004bbc54ec3a2b20c910d1045cbe46fb1c65eb18d0cb76e425718ca0
MD5 033e5988334b5e9167b20fd9ead37ce2
BLAKE2b-256 df1c131fa132dc54c65d20b34e6869ccf9252fb1e51f7a763375ade0e4570087

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fastipc-0.1.2-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c09cc4e91c66d9b3369d890a86c9f0bcd9ee60ab91d18cbe157ea8a29f46d4fb
MD5 c6aacdb151271c05a87dea0275120f45
BLAKE2b-256 256163fca28f09b9dc4ea867600cae2d3bf14e5a7d2acbdc41b7edb739241849

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.2-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.2-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.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9bd490a6a99ab6b424d74fa98cd4bcba2454a934a3dc18a76b548b8b4ef4c369
MD5 cc415c42f984a642c5d84621e400a458
BLAKE2b-256 314f3832aef316bb49c296b3a0d1b834ffb4988d9d4a20315faf3a8340f4f604

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.2-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.2-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.2-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 408f264feb9ad376b641f3f87a58f2e3508ee3c66c78377188b675e3a88c8030
MD5 c6674a493c8a9af10dddf40adb3649af
BLAKE2b-256 cfd5a9288a5debad30665c1a5ad81cd518dd8f2d2f8b50699429f03aea575c5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.2-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.2-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.2-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7a83b3edd1b13604abc4a26fd9066530d7e849c0af048aa4840c5a18bad83211
MD5 23daad6900086f4662aabc2c343d6b3e
BLAKE2b-256 9c01550330ce5334e08f97665cd68959fa7e77bbd6e9cb4f576f0e1a6b51bb62

See more details on using hashes here.

Provenance

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