Skip to main content
The Python adapter uses cffi (not ctypes) for FFI bindings. It wraps numpy’s np.frombuffer for zero-copy array views.

Installation

Or from source:

SharedRegion

create

Creates a new region. Raises OSError if the name already exists, the name is invalid, or the capacity is not page-aligned.

open

Opens an existing region. Raises OSError if the region does not exist or the header is corrupted.

as_buffer

Returns a memoryview backed directly by the shared mmap. No copying occurs.

as_numpy

Returns a numpy ndarray backed directly by the shared memory. No copying occurs. Requires numpy to be installed.
Without a dtype argument, it defaults to np.uint8.

notify

wait

Returns True if notified, False if timed out.

close

The region is also closed when the SharedRegion object is garbage collected or used as a context manager:

Example: numpy integration

The as_numpy call returns a view, not a copy. Writing to the array from either process modifies the same physical memory.

FFI details

The adapter loads libzinc_core.{so,dylib,dll} at import time. It reads zinc.h from include/ relative to the Python package to define the FFI signatures. If the header is missing, it falls back to a hardcoded CDEF. The library path is resolved relative to the Python package location. If the library is not found, copy it to a standard library path or set LD_LIBRARY_PATH / DYLD_LIBRARY_PATH.