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

Access _row and _col attributes directly in GridQubit instead of using properties #6075

Merged
merged 1 commit into from
Apr 22, 2023

Conversation

maffoo
Copy link
Contributor

@maffoo maffoo commented Apr 22, 2023

Using self._row and self._col attributes directly instead of properties in the internals of these classes provides a significant speedup, especially since these classes are heavily used. On an internal benchmark, this reduced the total time spent in GridQubit.__eq__ from 20.8s down to 5.7s, a 3.6x speedup.

There are other optimizations we might be able to make in the future, for example by "de-virtualizing" more methods to not rely on generic implementations in the base class, as we have already done for GridQubit.__eq__ itself, but for now this provides a welcome performance boost.

@maffoo maffoo requested review from a team, vtomole and cduck as code owners April 22, 2023 21:47
@maffoo maffoo requested a review from viathor April 22, 2023 21:47
@maffoo maffoo changed the title Access _row and _col attributes directly in GridQubit instead of using properties Access _row and _col attributes directly in GridQubit instead of using properties Apr 22, 2023
@maffoo maffoo merged commit 2a57894 into master Apr 22, 2023
@maffoo maffoo deleted the u/maffoo/grid-qubit-row-col branch April 22, 2023 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants