Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve support for Python 3.13 copy.replace #13286

Open
jakelishman opened this issue Oct 7, 2024 · 0 comments
Open

Improve support for Python 3.13 copy.replace #13286

jakelishman opened this issue Oct 7, 2024 · 0 comments
Labels
type: feature request New feature or request

Comments

@jakelishman
Copy link
Member

jakelishman commented Oct 7, 2024

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-facing copy.replace and the protocol-level object.__replace__. We should make sure that Qiskit objects that define a replace 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 example DataBin) that might want to begin supporting the behaviour.

@jakelishman jakelishman added the type: feature request New feature or request label Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant