SOL-DEPYLER-003 // depyler
Streaming Telemetry CSV Aggregator
Convert a memory-heavy Python dict accumulator into an O(1)-allocation Rust BTreeMap aggregator with deterministic key order.
Measured delta: 18.4x throughput vs CPython 3.12 with deterministic BTreeMap order
Before (Failing Anti-Pattern)
def agg_untyped(rows):
d = {} # insertion-order dependent, high GC overhead in CPython
for k, v in rows: d[k] = d.get(k, 0) + v
return d
After (Verified Code)
def sum_by_host(rows: list[tuple[str, int]]) -> dict[str, int]:
totals: dict[str, int] = {}
for host, count in rows:
totals[host] = totals.get(host, 0) + count
return totals
Verification Contract
schema: depyler.contract.v1 determinism: ordered_map: BTreeMap zero_panics: true
Verified CLI Command & Output
$ depyler transpile --deterministic agg.py -o agg.rs depyler: emitted BTreeMap aggregator (18.4x throughput vs CPython 3.12)