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.4.tar.gz (23.7 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.4-cp314-cp314-musllinux_1_2_x86_64.whl (56.0 kB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

fastipc-0.1.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (56.8 kB view details)

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

fastipc-0.1.4-cp313-cp313-musllinux_1_2_x86_64.whl (56.1 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

fastipc-0.1.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (56.8 kB view details)

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

fastipc-0.1.4-cp312-cp312-musllinux_1_2_x86_64.whl (56.0 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

fastipc-0.1.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (56.8 kB view details)

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

fastipc-0.1.4-cp311-cp311-musllinux_1_2_x86_64.whl (57.1 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

fastipc-0.1.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (57.7 kB view details)

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

fastipc-0.1.4-cp310-cp310-musllinux_1_2_x86_64.whl (56.2 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

fastipc-0.1.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (56.7 kB view details)

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

fastipc-0.1.4-cp39-cp39-musllinux_1_2_x86_64.whl (55.7 kB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

fastipc-0.1.4-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (56.3 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.4.tar.gz.

File metadata

  • Download URL: fastipc-0.1.4.tar.gz
  • Upload date:
  • Size: 23.7 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.4.tar.gz
Algorithm Hash digest
SHA256 3870c10bb6bfdf1c11a47d4174689df8045d1391734211bff840b12700e0fd05
MD5 809c9f301754a1a20c25fb8157ea7cd9
BLAKE2b-256 b2e1791370c5fd114d3ab02bcab528f10858c75d92bfb860a181ff45d481e912

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fastipc-0.1.4-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3849c2ccfcead6a04dd139d58e27f898a44e2cbb2ace87470d78320e90f99ca9
MD5 50093db32897cdc7872da1ebdaf6c93e
BLAKE2b-256 9f0ef36ce60c89cb0462aa6f7929df72c59ca99f6728c9b1eda577aa11a27c41

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.4-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.4-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.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7e5302d75ba432a1b87a0482732b362a11dea9ced2e3a7412dd1eb00b279236f
MD5 5bef653f07737ecbda02bde536836414
BLAKE2b-256 c22ecaeb0cb56e4e54d491fc05af55bc115b292cad4ef89b1ea04cdd6a350eed

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fastipc-0.1.4-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 01a9289712e46c6815ac9f136b262d2a7a5090c166531cefc2b9b4c55ec4fcf7
MD5 f20427900c083b546dd64def1d8687c4
BLAKE2b-256 a16e5fbc14f445a215c25b34f61b084950e03b7ffaaeacf53179168b4d1ff2e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.4-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.4-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.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0f8bf6341894e3604ec4a8bfde41fc1b58448845f15bd6ecf54cd58bdb08d442
MD5 b8e4c60e0a5bdeb1a84415d204acf047
BLAKE2b-256 62f97661165926dcf31d9b70bba9dfb7ad5bf603efbd7726bc862ad006cc7fae

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fastipc-0.1.4-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 17abfc6ca299aee2bf3782893ca6936e1569ff779cb847dcf5fa6a0606d5d5b9
MD5 92930097601e94fad1f73f6176e884f0
BLAKE2b-256 0c04a8c629626879e130239cf1549d16e62e9145a30acacd447f5187bc628ea9

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.4-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.4-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.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b72e127beb9ff280b98d8b25a834508cacb6e82b378dd3de839f69b03cd9c794
MD5 9bd973e11fb484983d3ec6a92ec566d8
BLAKE2b-256 0b203ff17c2ba87805587c7b5e7f1450a540aa252118a215c3049311900013f0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fastipc-0.1.4-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fa79d0a30bd29eb6cf1d7bc64156a76c425aad98205e0c65850a8f916390a948
MD5 ec6eb454b60e92a9578b3678b14de388
BLAKE2b-256 01233ef3a6bd1e47070ddd377d13c91ead3faef0404ab7967dfbac9ba07d8881

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.4-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.4-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.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 252e4a4610856257db41c23001efb2761a0e71d0db640b9349131f621001f4b7
MD5 b95b98ffcd5e2ba2962eff6dd4736da5
BLAKE2b-256 77d47f7976628fb6726b20b08bb600fb7ca635983fb3c54deea630cc85d46700

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fastipc-0.1.4-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5e7d70239a80daa93484e7be456087b1ccfcd0f6075a5a754d4a6d1e55b5047b
MD5 a03080b0c71fefa4874c1ea070ce6075
BLAKE2b-256 a72183d9288c1262e29eb146f92b8a8402f2560307dab2c08e04e36de7fb6d98

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.4-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.4-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.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8ba50d1377e8f0820812d5e41cb891cb36495eb1de43709c7f5a7149f25f96e8
MD5 971e0490ef3955bb7bfe559974486a8e
BLAKE2b-256 59f4b0405120914746697abbeccee6978a1bb158dd3796be1888fd852e4e805e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fastipc-0.1.4-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0efed4e95a4231e05ce5f00be824e33bf2e6c1d408045609170ba3d78e8157f8
MD5 1dc0803fd102d23a44a1a37bd000fd92
BLAKE2b-256 fa06c9bc88f3e733e6eb5eb9af1eb72d0150d86c6398edfec17d3d3955c0b507

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastipc-0.1.4-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.4-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.4-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d6da50f8ffad25de6e2263ef98368a0acaf9abc413ad542befcc435345284246
MD5 da2e7b66d1308d0c6f1564106d8f0c32
BLAKE2b-256 21ae9460f5de22736e1b515c900cbd46779faa0a1685892ce91a12226def306f

See more details on using hashes here.

Provenance

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