Skip to content

Commit

Permalink
cleanup instruction module, add comment explaining deepcopy
Browse files Browse the repository at this point in the history
  • Loading branch information
MarquessV committed Mar 25, 2024
1 parent 60a97f1 commit e8acd63
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rust/src/instruction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ impl Instruction {
inner: self_.inner.clone(),
};

// QubitPlaceholders are implemented with Arc and identified as unique by their pointer
// address. Since cloning an Arc just copies the pointer address, we have to create new
// placeholders for the copy, otherwise resolving a placeholder in the copy would also
// resolve them in the original (or vice-versa).
let mut placeholders: HashMap<
quil_rs::instruction::QubitPlaceholder,
quil_rs::instruction::QubitPlaceholder,
Expand All @@ -91,7 +95,10 @@ impl Instruction {
self.clone()
}

///
// This will raise an error if the program contains any unresolved
// placeholders. This is because they can't be converted to valid quil,
// nor can they be serialized and deserialized in a consistent
// way.
pub fn __getstate__<'a>(&self, py: Python<'a>) -> PyResult<Bound<'a, PyBytes>> {
Ok(PyBytes::new_bound(
py,
Expand Down

0 comments on commit e8acd63

Please sign in to comment.