-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Deprecating isinstance(qr[0], tuple) #2474
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine to me, it's a pretty big hack to inspect the call stack and look for a reference to tuple and dynamically change the response. But, I can't think of a better way. I do wonder if there will be a performance overhead for doing this in a property on a class that will be used everywhere, but we'll find out.
Before I hit Approve I do wonder if we want to clean up the tests at all. There are a bunch of deprecation warnings being emitted because of this and other tuple vs bit things, mostly in layout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I just checked and all the warnings being emitted from the layout module are about accessing or creating the layout with tuples, not anything to do with this. We can go and clean that up later.
This has made Aqua run much slower. for example, test_amplitude_estimation used to finish within 2 minutes; now it would take more than 13 minutes. |
I can confim that this is also the reason for the slow down observed in #2489 |
This reverts commit 3f60d53.
* initial from 2470 * __repr__ * undo repr * is_bit * silence when layout
This PR deprecates the
isinstance
for a Bit when checked for a tuple. It is some sort of hack, however, many users are checking forisinstance(qr[0], tuple)
and that is not supported after #2414By overwriting
__class__
, we pretend to be a tuple when isinstance is called in a context that mentions tuple.