Skip to main content

nil-gate

Python binding for nil-gate — a tiny, change-driven DAG library for C++20.

Features

  • Change-Driven Execution: Only recompute when inputs change
  • Type-Safe Ports: External, mutable, and read-only port abstractions
  • Multiple Runners: Choose between immediate, async, and soft-blocking execution strategies
  • Minimal Dependencies: Header-only C++ core with optional FFI bindings
  • Cross-Language: C++, Lua, Python, and extensible to other languages

Installation

pip install nil-gate

Quick Start

import nil_gate

# Create a core with SoftBlocking runner
core = nil_gate.create_core()

# Define a simple equality function
def eq(l, r):
    return l == r

# Setup: create a port and a doubling node
def doubler(args):
    args.outputs[0].set_value(args.inputs[0] * 2)

def setup(graph):
    port = graph.port(eq, 21)
    node_out = graph.node(
        doubler,
        [port],
        [eq],
    )
    return port, node_out.outputs()[0]

# Execute setup
port = out = None
def store_result(graph):
    global port, out
    port, out = setup(graph)

core.post(store_result)
core.commit()

# Update input and observe output
def update_input(graph):
    port.to_direct().set_value(42)

core.post(update_input)
core.commit()

print(out.value())  # Output: 84

core.destroy()

API Reference

Core

Main entry point for the graph execution engine.

core = nil_gate.create_core()
Method Description
commit() Flush pending mutations and trigger execution
post(fn) Schedule fn(graph) to run on next commit()
apply(fn) Run fn(graph) immediately and block until complete
destroy() Unset runner and destroy core; invalidates instance

Graph

Passed as an argument to post() / apply() callbacks. Do not store beyond callback scope.

Method Description
port(eq, value=None) Create external port with equality function
node(fn, inputs, outputs) Register a node with inputs and outputs

Ports

Three port types for different access patterns:

  • EPort — External port (created with graph.port())

    • to_direct() → MPort (mutable handle)
  • MPort — Mutable port (write and read values)

    • Inherits RPort read methods
    • set_value(v) / unset_value()
    • value() / has_value()
  • RPort — Read-only port (read values only)

    • value() / has_value()

NodeArgs

Argument passed to node execution callback.

Field Type Description
core Core Core handle (valid during call)
inputs list[Any] Current input values
outputs list[MPort] Output port handles

Memory Model

Lifetime Notes

Core instances are owning handles. The Python binding uses GC finalizers to call core.destroy() if the object is collected while still active. Finalizer timing is nondeterministic and may not run at shutdown, so call core.destroy() for deterministic teardown.

Graph objects passed to post()/apply() callbacks are non-owning views and must not be stored or destroyed. The NodeArgs instance passed to node functions is also borrowed and only valid for the duration of the callback.

Documentation

For detailed API documentation and more examples, visit:

License

CC BY-NC-ND 4.0

Support

For issues, questions, or contributions, visit the GitHub repository.

Metadata

Release files for nil-gate 1.6.9

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 nil-gate 1.6.9
File Interpreter ABI Platform Actions
nil_gate-1.6.9-py3-none-manylinux_2_35_x86_64.whl Python 3 none Linux glibc 2.35+ x86-64 Details for nil_gate-1.6.9-py3-none-manylinux_2_35_x86_64.whl
nil_gate-1.6.9-py3-none-any.whl Python 3 none any Details for nil_gate-1.6.9-py3-none-any.whl

Total release size: 86.2 kB

Release files / nil_gate-1.6.9-py3-none-manylinux_2_35_x86_64.whl

Download URL nil_gate-1.6.9-py3-none-manylinux_2_35_x86_64.whl
Size 43.2 kB
Tags Linux glibc 2.35+ x86-64 Python 3
SHA-256 checksum
How to use checksums
ceb96c857f18a6db50a0d2abef3bec32f20b2108569cd26dda7cf9e1cfe5d3f1
BLAKE2b-256 checksum
How to use checksums
288805fff7300f4df45468448f928b2e02db7c45f7c8df822ca2373a47041611
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / nil_gate-1.6.9-py3-none-any.whl

Download URL nil_gate-1.6.9-py3-none-any.whl
Size 43.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ef8c464d837f891d90f79b5b7a80d7dc359a7f08bbac8a811055b5e8e749532
BLAKE2b-256 checksum
How to use checksums
843cb8b8e0318d6fa7c74c3e0211281ac19ecb7f16cbb8f3c5f53f76224910c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for nil-gate 1.6.9

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.

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