API & CLI

Run it from the terminal
or embed it in Rust.

pyFlow is a command-line runner, a REPL, and a Rust library. Every path returns the same thing: the answer, and the energy it took.

Command line

terminal
# run a file, print the result
$ pyflow run app.py

# or start the REPL: every line is metered in joules
$ pyflow
pyflow> def sq(x): return x * x
pyflow> sq(9)
81    [14 pJ, est.]

# see the per-op receipt for an example
$ pyflow --example receipt

Embedding

The engine is a Rust crate. Drop it into any host to run Python-subset programs with a joules receipt, no interpreter to embed and no network round-trip.

main.rs
use pyflow::{Session, run_receipt};

// one-shot: source + args in, result + energy receipt out
let (result, receipt) = run_receipt(
    "def poly(a, b): return (a + b) * (a - b)",
    &[5, 3],
)?;
assert_eq!(result, 16);
println!("{} pJ", receipt.total_pj);   // 16 pJ

// stateful: a persistent REPL session
let mut s = Session::new();
s.run_module("x = 7
def inc(n): return n + 1")?;
let out = s.eval("inc(x)")?;         // 8

Public surface

run(src, &[i64]) -> Result<i64>
Run a single function, integer args and result.
run_value(src, &[Value]) -> Value
Typed args and result: ints, floats, strings, lists, dicts.
run_receipt(src, &[i64]) -> (i64, EnergyReceipt)
Result plus the itemized picojoule breakdown.
Session::eval / run_module
A stateful REPL session; defs and globals persist.
EnergyReceipt { total_pj, per_op, measured }
The bill: total, per-operation, and whether it was measured.

Roadmap