-
Notifications
You must be signed in to change notification settings - Fork 356
Description
Pre-Report Checklist
- I am running the latest versions of pyQuil and the Forest SDK
- I checked to make sure that this bug has not already been reported
Issue Description
The Program class was made hashable in a previous release:
Line 969 in 6573ed0
| def __hash__(self) -> int: |
However, the hash is based on the textual output (.out() method) and this is mutable because the list of instructions, calibrations etc are all mutable and contribute to the value. An instance of Program could be used as a dictionary key but the value could also change, making the dictionary behavior undefined.
See also:
Line 969 in 6573ed0
| def __hash__(self) -> int: |
Suggested Fix
There is no non-breaking fix for this issue. The least-jarring fix is to remove the method and to provide a FrozenProgram or equivalent which, in the case that the user was careful to avoid mutation in their workflow, would provide a new class to be used in place of Program with the same hash support. The preferred implementation would likely leverage solutions to:
and