Skip to main content

Zef 🌿

A Rust-powered Python platform for building reactive, data-driven applications with managed effects, actor-based concurrency, content-addressable functions, and a refinement type system.

Zef treats everything — types, functions, effects, errors — as plain data. Values are contiguous in memory (like FlatBuffers), require no serialization, and cross language and process boundaries without conversion overhead.

What does Zef look like?

Composable Pipelines

from zef import *

names = ['Alice', 'Bob', 'Charlie', 'Dave']

names | filter(Z | length | greater_than(3)) | sort | collect
# ['Alice', 'Charlie', 'Dave']

range(10) | filter(is_prime) | map(multiply(2)) | collect
# [4, 6, 10, 14]

Effects as Data

Side effects are values you construct and then execute. There's a clear syntactic boundary between describing what to do and actually doing it.

# Describe the effect — this is just data
effect = FX.StartHTTPServer(
    routes={
        '/':       ET.HTML(content='<h1>Hello!</h1>'),
        '/api':    ET.JSON(content={'status': 'ok'}),
        '/health': ET.JSON(content={'up': True}),
    },
    port=8080,
)

# Execute it
effect | run

Actors and Streaming

Actors subscribe to topics, receive messages, and produce effects. State is threaded through successive invocations.

from zef import *

topic = ET.Topic('🍃-a0b1c2d3e4f567890abc')   # use the pub-sub system

def handle_msg(msg, state):
    effects = [FX.Print(content=f"[{state}] got: {msg}")]
    new_state = state + 1
    return effects, new_state

FX.StartActor(
    input=topic,
    initial_state=0,
    rules={(Any, Any): handle_msg},
) | run

# Send messages — the actor processes them
FX.Publish(target=topic, content='hello') | run
FX.Publish(target=topic, content='world') | run
# [0] got: hello
# [1] got: world

Refinement Types

Types are sets. Compose them with & (intersection) and | (union). Refine with predicates.

Positive = Int & (Z > 0)
SmallPositive = Positive & (Z < 100)

42 | is_a(SmallPositive) | collect    # True
-1 | is_a(SmallPositive) | collect    # False
200 | is_a(SmallPositive) | collect   # False

# Use in function dispatch
EvenInt = Int & (Z % 2 == 0)

Multiple Dispatch

Functions support multiple methods dispatched on argument types — like Julia, but in Python.

@zef_function
def greet(x: String) -> String:
    return f"Hello, {x}!"

@zef_function
def greet(x: Int) -> String:
    return f"Number: {x}"

greet("Alice")   # "Hello, Alice!"
greet(42)        # "Number: 42"

Core Ideas

  • Data-oriented. If it can be expressed as data, it should be. Effects, errors, types, functions — all values.
  • Entity identity. Entities can be unnamed, locally named, graph-local, or UID-addressed; see Entity Names, UIDs, and Local Identity.
  • Managed effects. Side effects are declared as values with FX.*, then executed with | run. Pure core, imperative shell.
  • Contiguous memory. Zef values live in contiguous buffers — no pointer chasing, no serialization. The in-memory format is the wire format.
  • Refinement types. Types are sets. Int & (Z > 0) is a type. Compose freely.
  • Content-addressable functions. A function is a value identified by its content hash, not its name. Multiple names can point to the same function, and any machine that can find its content in a Zef Store can call it. Methods are hot-reloadable.
  • Actor concurrency. Actors subscribe to topics, process messages, and produce effects. State is explicit and threaded.
  • Cross-language. Rust core with Python bindings (via PyO3). The same binary data flows between languages without marshaling.

Getting Started

Install from Wheel

Download the latest wheel from GitHub Releases and install:

pip install zef_core-*.whl

Build from Source

git clone git@github.com:UlfBissbort/zef.git
cd zef

# Create a virtual environment
python3 -m venv dev_venv
source dev_venv/bin/activate

# Install maturin
cargo install maturin --locked

# Build and install (release mode recommended — debug is significantly slower at runtime)
cd zef_core
maturin develop --release --features py_bindings

To see the Rust compilation phase breakdown, run this from zef_core with nightly Rust:

maturin develop --release -- -Ztime-passes 2>&1 | tee ~/dev/scratch/zef-error-compile-phases.log

Configure

Create ~/.config/zef/config.zen.py:

ET.ZefConfig(zef_source_dir='/path/to/zef', vault_=['~/zef-vault'])

Verify

>>> import zef
🚅 created shelf allocator of size 64.00 GB on thread ThreadId(1)
🌿 Zef import completed

>>> zef.__version__
'0.1.14'

Running Tests

# Rust tests
cd zef_core && cargo test

# Python tests — run all with the test runner
python run_tests.py

# Run specific tests by pattern
python run_tests.py int64 skip

# Run a single test file directly
python tests/test_int64_layout.py

See notes/How to Write Tests in Zef.md for the full testing guide.

CI/CD

python trigger_build.py                      # interactive menu, in a terminal
python trigger_build.py release --dry-run    # preview the next PyPI release; changes nothing
python trigger_build.py release --yes        # release: tag and push (starts CI), build and test locally, upload
python trigger_build.py bump minor --yes     # bump the minor version and trigger CI, without publishing

See notes/Release and Build System - Hands-On Guide and Deep Dive.md for the full flow.

Documentation

The notes/ directory is a linked knowledge base covering architecture, design decisions, and implementation details. Start with notes/Overview.md for the index.

Key guides:

The zefop-search.html file is a standalone searchable reference for all Zef operators.

Tip: The notes use [[wiki-link]] cross-references and work as an Obsidian vault — open notes/ in Obsidian for a browsable, linked view.

Status

Zef is under active development. The API is evolving. The core data structures, type system, effects system, and actor model are functional. Language support is currently Python and Rust, with TypeScript (via WebAssembly) planned.

The Rust codebase produces compiler warnings — a cleanup pass is planned once the type definitions move to the code graph and source generation is unified.

Building Wheels

Wheels are pre-built binary packages for distribution via PyPI or direct install.

The extension_module Gotcha

PyO3's extension-module feature controls how the native library links against Python. Without it, the .so gets hardlinked to the specific libpython from the build environment. The wheel then only works on the exact same Python build — install it on a different one (e.g. homebrew) and you get:

Fatal Python error: PyInterpreterState_Get: the function must be called
with the GIL held ... but the GIL is released

The extension_module feature is configured in pyproject.toml, but maturin only reads it when run from the project root. The build command must use -m to point at the sub-crate:

# ✅ Correct — reads pyproject.toml, applies extension_module feature
cd /path/to/zef
maturin build --release -m zef_core/Cargo.toml

# ❌ Wrong — skips pyproject.toml, wheel crashes on non-build Python
cd zef_core
maturin build --release

Verify the build output includes 📡 Using build options features from pyproject.toml and does not show a warning about extension-module.

Cross-Compiling for Linux

# Linux x86_64 (requires Docker or cross toolchain)
maturin build --release -m zef_core/Cargo.toml --target x86_64-unknown-linux-gnu

# Linux ARM
brew install zig
rustup target add aarch64-unknown-linux-gnu
maturin build --release -m zef_core/Cargo.toml --target aarch64-unknown-linux-gnu --zig

Metadata

Release files for zef 0.1.97

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for zef 0.1.97
File Interpreter ABI Platform Actions
zef-0.1.97-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details for zef-0.1.97-cp310-abi3-manylinux_2_28_x86_64.whl
zef-0.1.97-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details for zef-0.1.97-cp310-abi3-manylinux_2_28_aarch64.whl
zef-0.1.97-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for zef-0.1.97-cp310-abi3-macosx_11_0_arm64.whl

Total release size: 103.5 MB

Release files / zef-0.1.97-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL zef-0.1.97-cp310-abi3-manylinux_2_28_x86_64.whl
Size 35.5 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
c96e57eb6a68dfa43d6ec2a1f02db0c750bb4115b5b83c26379d7ee5018b9469
BLAKE2b-256 checksum
How to use checksums
3746f503e2002662ae93bbbc87ed18a97b6d563d212180f7c00ae455c8b3c802
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / zef-0.1.97-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL zef-0.1.97-cp310-abi3-manylinux_2_28_aarch64.whl
Size 35.7 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
25bb0077863738243c8d1e1853d7d19eff5b553ef8cdf3fb7a7c6e354378b2c2
BLAKE2b-256 checksum
How to use checksums
0cd696c1eb2e9e6ffac15b0fc2e8bfa03d0219731800a6843415b9f1f6fe9584
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / zef-0.1.97-cp310-abi3-macosx_11_0_arm64.whl

Download URL zef-0.1.97-cp310-abi3-macosx_11_0_arm64.whl
Size 32.3 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7a3dce90eb7a6a568b368a6c65d6acded2e400332e7c829cdcfa1e3dcf3f3b50
BLAKE2b-256 checksum
How to use checksums
2901ccd6f1379e855a157aafa1cceafdc7eeac904e3bfd574e434853aa1e7fb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Security for zef 0.1.97

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.97 This release

3 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page