From 0b5f59b7d8f4b60637799ada63e7e0847da2c9a4 Mon Sep 17 00:00:00 2001 From: Raynel Sanchez <87539502+raynelfss@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:15:53 -0500 Subject: [PATCH] Docs: Add relevant comment --- crates/circuit/src/circuit_data.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/circuit/src/circuit_data.rs b/crates/circuit/src/circuit_data.rs index 699ad5f3d1c0..fa36d8b841fb 100644 --- a/crates/circuit/src/circuit_data.rs +++ b/crates/circuit/src/circuit_data.rs @@ -1392,8 +1392,11 @@ impl CircuitData { #[cfg(feature = "cache_pygates")] { // Standard gates can all rebuild their definitions, so if the - // cached py_op exists, update the `params` attribute and clear out - // any existing cache. + // cached py_op exists, discard it to prompt the instruction + // to rebuild its cached python gate upon request later on. This is + // done to avoid an unintentional duplicated reference to the same gate + // instance in python. For more information, see + // https://github.com/Qiskit/qiskit/issues/13504 previous.py_op.take(); } } else {