CQCL / guppylang

Pythonic quantum-classical programming language
Apache License 2.0
18 stars 2 forks source link

Keep the Hugr around after compiling a module #246

Closed aborgna-q closed 2 weeks ago

aborgna-q commented 2 weeks ago

Right now calling GuppyModule.compile throws an error if the module has already been compiled.

In some cases we may want to use a module multiple times, for example when generating multiple circuits from it. Currently the work around is to manually keep the HUGR around, but it would be more straightforward if we can keep a reference to compiled hugr in the module.

@guppy(module)
def my_func():
  pass

@guppy(module)
def my_other_func():
  pass

make_circuit(module, "my_func")
make_circuit(module, "my_other_func") # This cannot access the hugr anymore