Sorry, something went wrong.
|
Is this a correctness issue or merely a performance issue? |
Sorry, something went wrong.
|
This is merely a performance issue. Without this change, the CONTAINS_OP will treat the proxy as a normal iterable and check the keys one by one. The iter() method worked fine so the result is correct. A list of keys will be generated and iterated. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM! (PR title tweaked to better reflect its purpose)
Sorry, something went wrong.
Currently the more efficient contains function is not used when someone does key in frame.f_locals because that defaults to sq_contains and it's not properly hooked. The function is only called when using frame.f_locals.__contains__(key).
This hooks sq_contains so the in operation is much more efficient.