OpDef#

class hugr.ext.OpDef(name: str, signature: ~hugr.ext.OpDefSig, description: str = '', misc: dict[str, ~typing.Any] = <factory>, lower_funcs: list[~hugr.ext.FixedHugr] = <factory>)[source]#

Bases: ExtensionObject

Operation definition in an Extension.

Methods

get_extension

Retrieve the extension associated with the object.

instantiate

Instantiate an operation from this definition.

qualified_name

Attributes

description

A description of the operation.

name

The name of the operation.

signature

The type signature of the operation.

misc

Miscellaneous information about the operation.

lower_funcs

Lowerings of the operation.

description: str = ''#

A description of the operation.

get_extension() Extension#

Retrieve the extension associated with the object.

Returns:

The extension associated with the object.

Raises:

NoParentExtension – If the object is not associated with an extension.

instantiate(args: Sequence[tys.TypeArg] | None = None, concrete_signature: tys.FunctionType | None = None) ops.ExtOp[source]#

Instantiate an operation from this definition.

Parameters:
  • args – Type arguments corresponding to the type parameters of the definition.

  • concrete_signature – Concrete function type of the operation, only required

  • polymorphic. (if the operation is)

lower_funcs: list[FixedHugr]#

Lowerings of the operation.

misc: dict[str, Any]#

Miscellaneous information about the operation.

name: str#

The name of the operation.

signature: OpDefSig#

The type signature of the operation.