Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:1kbgz Tributary Lazy Stream Bridge

From Leeroopedia
Knowledge Sources
Domains Lazy_Evaluation, Streaming
Last Updated 2026-10-14 00:00 GMT

Overview

A bridging pattern that connects pull-based lazy evaluation with push-based reactive streaming by wrapping lazy nodes as streaming source functions that are called on each tick.

Description

The lazy-stream bridge connects two fundamentally different evaluation paradigms:

  • Lazy (pull): Values are computed on demand when requested. Inputs change, dirty flags propagate, and re-evaluation happens only when the output is called.
  • Streaming (push): Values are pushed forward through the graph on each tick. Each node fires when its inputs arrive.

The bridge converts a lazy node into a streaming Func source. On each streaming tick, the Func calls the lazy node's __call__ method, which:

  1. Re-evaluates if dirty (because lazy inputs changed)
  2. Returns the cached value if clean

This creates a hybrid system: lazy computations can be embedded in streaming pipelines, benefiting from lazy caching and dirty propagation while participating in real-time data flow.

Usage

Use this principle when you want to combine the best of both paradigms:

  • A lazy financial model that should re-evaluate when parameters change, integrated into a real-time market data stream
  • A lazy computation graph that serves as a source for downstream streaming transforms
  • Converting between lazy and streaming without rewriting the computation logic

Theoretical Basis

The bridge implements a pull-to-push adapter: it wraps a pull-based computation in a push-based source.

# Abstract bridge model (NOT real implementation)
def lazy_to_streaming(lazy_node):
    def streaming_func():
        return lazy_node()  # pull: evaluate lazy graph
    return Func(func=streaming_func)  # push: emit on each tick

The key insight is that lazy evaluation is on-demand and streaming is on-tick. The bridge calls the lazy evaluation on each streaming tick, making the lazy graph a source in the streaming pipeline.

stream(lazy(n))=Func(λ:n())

Where n() triggers lazy re-evaluation only if n is dirty, otherwise returns the cached value.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment