active library

zeroipc

Started 2024 Python

Resources & Distribution

Package Registries

ZeroIPC - High-Performance Shared Memory IPC

Zero-copy data sharing between processes in C++, Python, Go, and C. No serialization, no bindings — parallel native implementations of the same binary format.

What’s New (v2.2.0)

  • Fixed critical concurrency bugs in lock-free Queue and Stack (head/tail confusion, fence placement)
  • Go implementation with generics, CLI tool, and cross-language interop
  • 9 synchronization primitives: Mutex, RWLock, Monitor, Event, Semaphore, Barrier, Latch, Once, Signal

Quick Start

C++ writes, Python reads — zero-copy:

#include <zeroipc/memory.h>
#include <zeroipc/array.h>

zeroipc::Memory mem("/sensor_data", 10*1024*1024);  // 10MB
zeroipc::Array<float> temps(mem, "temperature", 1000);
temps[0] = 23.5f;
from zeroipc import Memory, Array
import numpy as np

mem = Memory("/sensor_data")
temps = Array(mem, "temperature", dtype=np.float32)
print(temps[0])  # 23.5
mem, _ := zeroipc.OpenMemory("/sensor_data", 10*1024*1024)
defer mem.Close()
temps, _ := zeroipc.OpenArray[float32](https://github.com/queelius/zeroipc/blob/master/mem, "temperature")
fmt.Println(temps.Get(0))  // 23.5

Data Structures

Core — Array, Queue (lock-free MPMC), Stack (lock-free), Ring, Map (lock-free), Set, Pool, Table

Sync — Semaphore, Mutex, RWLock, Monitor, Barrier, Latch, Once, Event, Signal

Codata — Future, Lazy, Stream (with map/filter/fold), Channel (CSP-style)

Design Principles

All implementations follow the same binary specification. The metadata table stores only name, offset, and size — no type information. This enables true language independence: C++ uses templates, Python uses NumPy dtypes, Go uses generics. Users ensure type consistency across languages.

[Table Header][Table Entries][Structure 1][Structure 2]...[Structure N]

Key design choices:

  • Language equality — no language is “primary”; all are first-class implementations
  • Zero dependencies — each implementation stands alone
  • Lock-free concurrency — atomic CAS operations, no kernel calls in hot paths
  • User-controlled layout — no GC, no defragmentation, no hidden allocations

Language Implementations

LanguageDirHighlights
C++cpp/Header-only, C++23 templates, RAII
Gogo/Go 1.21+ generics, CLI tool
Pythonpython/Pure Python, NumPy integration, mmap
Cc/C99, zero dependencies, static lib

Building and Testing

# C++
cmake -B build cpp && cmake --build build
cd build && ctest --output-on-failure    # fast + medium tests (~2 min)

# Go
cd go && go test ./zeroipc/...

# Python
cd python && pip install -e . && python -m pytest tests/

# C
cd c && make && make test

# Cross-language
cd interop && ./test_interop.sh
cd go && go run ./cmd/interop

CLI Tool

cd go && go build -o zeroipc ./cmd/zeroipc

./zeroipc list                              # List shared memory segments
./zeroipc show /sensor_data                 # Inspect segment and structures
./zeroipc array /sensor_data temperatures   # Inspect specific structure
./zeroipc monitor /sensors temp_stream      # Real-time stream monitoring
./zeroipc repl /sensor_data                 # Interactive exploration

Supports all 16 structure types.

Use Cases

ZeroIPC is for single-machine, multi-process scenarios:

  • High-frequency sensor data sharing
  • Multi-process simulations and scientific computing
  • Real-time analytics pipelines
  • Cross-language data processing

Not designed for: network distribution, persistent storage, or general-purpose memory allocation.

Documentation

Contributing

  1. Follow the binary specification exactly
  2. Implement Memory, Table, and Array as minimum
  3. Add cross-language tests in interop/

License

MIT

Discussion