Expand description
Python-backed Copper tasks.
This crate exists for rapid algorithm prototyping, not for production realtime robotics.
A PyTask lets Copper keep ownership of scheduling, logging, replay, and task
lifecycle while delegating one task’s algorithm body to a Python function:
def process(ctx, input, state, output):
...Two execution modes are available:
PyTaskMode::Process: spawn a separate interpreter and exchange length-prefixed CBOR frames over stdin/stdout. This avoids putting the GIL inside the Copper process, but adds another serialization layer, extra copying, allocations, IPC overhead, and scheduler jitter.PyTaskMode::Embedded: call Python in-process through PyO3. This avoids the external CBOR transport, but executes under the GIL inside the Copper process and still allocates and converts values on every call.
Both modes are fundamentally at odds with Copper’s design center: predictable low-latency execution with minimal allocation on the realtime path. Using Python here will increase latency, jitter, and allocation pressure enough to ruin the realtime characteristics of the stack. Compared to a native Rust Copper task, the performance is abysmal.
The intended workflow is narrow:
- prototype one task quickly in Python
- stabilize the algorithm
- rewrite it in Rust, optionally using an LLM-assisted translation as a first draft
Do not treat Python tasks as a normal production integration path.
Structs§
- PyTask
- A Copper task whose
process(...)implementation is provided by a Python script.
Enums§
Traits§
- PyInput
Spec - Describes how a Python-backed task receives its Copper inputs.
- PyOutput
Spec - Describes how a Python-backed task exposes Copper outputs.
- PyTask
State - State carried across invocations of a
PyTask.
Type Aliases§
- PyUnary
Task - Convenience alias for the common one-input, one-output case.