Principle:1kbgz Tributary Lazy Stream Bridge
| 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:
- Re-evaluates if dirty (because lazy inputs changed)
- 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.
Where triggers lazy re-evaluation only if is dirty, otherwise returns the cached value.