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.1.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.1-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.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (30.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

fastipc-0.1.1-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.1-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.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (30.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

fastipc-0.1.1-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.1-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.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (30.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

fastipc-0.1.1-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.1-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.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (30.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

fastipc-0.1.1-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.1-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.1-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (30.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

fastipc-0.1.1-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.1.tar.gz.

File metadata

  • Download URL: fastipc-0.1.1.tar.gz
  • Upload date:
  • Size: 23.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for fastipc-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a4e703ad478108766aa1531883d111664fac162e3af843f3e00a2b451e4ed2cc
MD5 c75f724426a93ef7548cd089e2386891
BLAKE2b-256 917de78462bcdc6257279bcdb567bf792b62161e5990d858b8f8c32c2d5ea7ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastipc-0.1.1-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 845ff2af407d913ca582571f39fcfb965984125bb3bc8db9b69f5dbf2c5d6cb5
MD5 c837c7f60bb4704e492f4b55ac2a4343
BLAKE2b-256 c04a1f819cc8fcb9b4a022e7c107add61ec9e0ddafc2e50c2eed3d3e5e0ed20b

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.1-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.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 24404dd23979c45812589a73344d3345bc5ffa81416c70e4b676e64064efca05
MD5 0dccdb3877487af106d71101f7e96307
BLAKE2b-256 81f0a7efa0abd36cb1eb47ccdb5015630075a8475ca2c51d9dfdc9f1f7c1f4e0

See more details on using hashes here.

File details

Details for the file fastipc-0.1.1-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.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9e26067a455bb0d76bac4e49493f5d13b9303df5501686ab08abd0ec76e645ce
MD5 99fe83e14ff1fab6db0d1040c494df31
BLAKE2b-256 1f63b9c17d745cf58eb1330f63f2e9394b61fa9e3a96bf6d2fca062bf0d3f052

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fastipc-0.1.1-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d1f88571c80fdd737483e283bd98c96061d2e844f5953b4b81b8549e994800cd
MD5 a3002704aa5ffec7442a1b96858c98bb
BLAKE2b-256 c257057ae6a2e8142ba519d5a82c98d1f6bab58c5c615912fbee4462325cf990

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.1-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.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 ae9e9d9406c90a92b577bcd210c8351025fdfe4caa6595e2cb4577a19a58b244
MD5 ad107b33104c917290b181747398beea
BLAKE2b-256 342c13153eaca907664f184b5b2069c35543ac07f9fda9796c9e10ffa8ccee52

See more details on using hashes here.

File details

Details for the file fastipc-0.1.1-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.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 48245b293a3a1e9f71a024f0256a110db5b789cba61521e62818cdbeede91931
MD5 2e76659ecf5f8a99e5fcb940a1466e2e
BLAKE2b-256 41aa5a4ecb5a80e2c5fe4f3c91365a443bffb906ec389d9783b8aefdef600220

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fastipc-0.1.1-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 80040a25132a0fb2c4db95b3eff042d9ad640d4c36e436de4c51e1c930c73f91
MD5 5dfaaa23fcf435dc948445d1e70a10d1
BLAKE2b-256 6a064e1c44fd464b0f1b0c1cbf3e53f92d02c4c724a0d17f38fdf3570ce81104

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.1-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.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 fff9e7257872be43f657c42a2308485aa2cdfac10d9d8123b431794be1c2bdae
MD5 3cd3497656fee803e60cb8494f9772af
BLAKE2b-256 82ba5d05257db43bf911dc5297d8a39db7264090bec9561f534f897ae5b67b2b

See more details on using hashes here.

File details

Details for the file fastipc-0.1.1-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.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5ff4d9c73851451a69d8378c8e5cdf0eb2d5c05554b73cb70519ee1f522af63f
MD5 ab3e525ad810fc50e4420db10d245a3c
BLAKE2b-256 44f910c65381c547d91bfdd27fb1e6b5d38a890a3699bedd711638cabb5913a6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fastipc-0.1.1-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2ba6f16f8165a2919c0038af833280e9bfe3bf01615f6b6e29f6dfb930d0260c
MD5 822e4e483638f77b703fbb80ebeeb4c8
BLAKE2b-256 a75f69e3f626f5570f3409f6dca72d493a664f1403f562e2b38ac545cfad8e81

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.1-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.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for fastipc-0.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 86f45f16725819047ffd5bac2e1151a19beffa88825f012aad393c07a88457c5
MD5 8a23a0a65c0e5c8f665a6622edc0cba1
BLAKE2b-256 13c1c42f1725a196e3b53a692364d26f290c3c267054d202d32113b5521e290b

See more details on using hashes here.

File details

Details for the file fastipc-0.1.1-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.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d42c8cf0d643a926e4f1a73a1b7979c6ddf022285ec18d7470691f50f322c697
MD5 f82c363e4857c6ab7aaa3bb1fef683f6
BLAKE2b-256 cbe73d28153fc5a2eb6cce89da4258ce283d0c9fad061606e418391de67cc0d3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fastipc-0.1.1-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ebdda08c44521b5b44e263373bd267f569f8e69779890eda53f8dab12666536d
MD5 43e383d2286801acc49eaa162a9e4683
BLAKE2b-256 6273ad307c74ddb0ad71aed6f739c7ff732bc0ed5ba08ee60185f17e729a47f5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fastipc-0.1.1-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 b6794dea30faab5cbb4e6ba73f751af4cc0638c795b5f68290cf0fba68ab27ad
MD5 a0102c84e1c46750b7871ffeff744cf4
BLAKE2b-256 f2d060cdc06c04107c36299a883acab3d27b70ca04fc3eb51ba34af0299e6259

See more details on using hashes here.

File details

Details for the file fastipc-0.1.1-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.1-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3b97a04776caed24084f3e3a901b516443925652b037495c67c29ca529db8180
MD5 a43c1002640dcee1cc050f85d571ae2a
BLAKE2b-256 3e28e9450895314a0cf28e8b25b69816417d0f6b9f9a90b48bcafa0ae3852a7f

See more details on using hashes here.

Provenance

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