diff --git a/crates/circuit/src/circuit_data.rs b/crates/circuit/src/circuit_data.rs index d87efd03ac5d..3249b609e154 100644 --- a/crates/circuit/src/circuit_data.rs +++ b/crates/circuit/src/circuit_data.rs @@ -1284,6 +1284,11 @@ impl CircuitData { } Ok(()) } + + /// Retrieves the python `Param` object based on its `ParameterUuid`. + pub fn get_parameter_by_uuid(&self, uuid: ParameterUuid) -> Option<&Py> { + self.param_table.py_parameter_by_uuid(uuid) + } } /// Helper struct for `assign_parameters` to allow use of `Param::extract_no_coerce` in diff --git a/crates/circuit/src/parameter_table.rs b/crates/circuit/src/parameter_table.rs index 8825fbd71772..38cabf10c69f 100644 --- a/crates/circuit/src/parameter_table.rs +++ b/crates/circuit/src/parameter_table.rs @@ -225,6 +225,11 @@ impl ParameterTable { .map(|uuid| &self.by_uuid[uuid].object) } + /// Lookup the Python parameter object by uuid. + pub fn py_parameter_by_uuid(&self, uuid: ParameterUuid) -> Option<&Py> { + self.by_uuid.get(&uuid).map(|param| ¶m.object) + } + /// Get the (maybe cached) Python list of the sorted `Parameter` objects. pub fn py_parameters<'py>(&mut self, py: Python<'py>) -> Bound<'py, PyList> { if let Some(py_parameters) = self.py_parameters.as_ref() {