implement_ops¶
- guppyft.encode.implement_ops(hugr_pkg, spec, *, as_bytes=False)[source]¶
Enriches the given package using the given spec by replacing all operations in the program with function calls to the functions in spec.ops.
- Overloads:
hugr_pkg (Package), spec (ImplementOpsSpec), as_bytes (Literal[False]) → Package
hugr_pkg (Package), spec (ImplementOpsSpec), as_bytes (Literal[True]) → bytes
hugr_pkg (Package), spec (ImplementOpsSpec), as_bytes (bool) → Package | bytes
- Parameters:
hugr_pkg – A package containing a single module.
spec – The specification for the operation implementation.
as_bytes – Whether to return bytes instead of a Package, skipping final deserialization.
- Returns:
The enriched function as an executable HUGR package, or its serialized representation when as_bytes is True.