You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have some classes that act like immutable record types. These often define a custom replace method to allow constructing a new version of the class while making limited changes to a subset of fields. These classes tend now to be the ones defined in Rust space (CircuitInstruction is a prime example, but there may be more).
At the time of writing, I'm only aware of CircuitInstruction that does this verbatim, but it's possible that we have other classes that are dataclass-like (for example DataBin) that might want to begin supporting the behaviour.
The text was updated successfully, but these errors were encountered:
What should we add?
We have some classes that act like immutable record types. These often define a custom
replace
method to allow constructing a new version of the class while making limited changes to a subset of fields. These classes tend now to be the ones defined in Rust space (CircuitInstruction
is a prime example, but there may be more).Python 3.13 formalised this idea into a part of the
copy
module /pickle
protocol, with the user-facingcopy.replace
and the protocol-levelobject.__replace__
. We should make sure that Qiskit objects that define areplace
function with the same semantics expose the same behaviour as__replace__
to improve interoperability with later language features.At the time of writing, I'm only aware of
CircuitInstruction
that does this verbatim, but it's possible that we have other classes that are dataclass-like (for exampleDataBin
) that might want to begin supporting the behaviour.The text was updated successfully, but these errors were encountered: