Skip to content

Python: bind timed #938

Description

@0-jake-0

StreamOps::timed (crates/wingfoil/src/fluent.rs, next to print) passes each value through unchanged and prints a performance summary at the end of the run. It is not exposed in Python — grep -rn '\btimed\b' crates/wingfoil-python/src finds only unrelated hits.

Its neighbour print is bound, and the two are the same shape, so this is a small, well-modelled first contribution to the Python crate.

Where to start

PyStream::print in crates/wingfoil-python/src/graph.rs (~line 662) is the model. The binding is one line over the erased PyElement edge plus rustdoc:

pub fn timed(&self) -> PyStream {
    self.wrap(self.stream.timed())
}

Check the bound before assuming it compiles: timed wants T: Clone + Default + 'static and PyElement satisfies that (print additionally needs Debug and gets it). If it does not compile, say so on the issue rather than working around it — that would be a real finding about the erased edge.

The recipe for the Python step is /new-op §7 (.claude/commands/new-op.md), which distinguishes the one-line forward (an op whose Out is T, which this is) from the hand-written register_op1 needed for tuple outputs.

Acceptance criteria

  • PyStream::timed exists, with rustdoc saying what it prints and when (end of run, not per tick).
  • A Rust-side unit test in graph.rs's mod tests, next to the print / inspect ones, asserting values pass through unchanged.
  • A pytest under crates/wingfoil-python/tests/ covering the same from the Python side.
  • If the readthedocs API page lists methods explicitly (crates/wingfoil-python/docs/), timed is added there too.
  • cd crates/wingfoil-python && maturin develop && pytest passes; cargo fmt --all and cargo lint-all clean.

Branch from main, target base main. See CONTRIBUTING.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions