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

bpo-39902: support equality comparisons in dis.Bytecode #18849

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

isidentical
Copy link
Sponsor Member

@isidentical isidentical commented Mar 8, 2020

@@ -536,6 +536,16 @@ def dis(self):
lasti=offset)
return output.getvalue()

def __eq__(self, other):
Copy link
Sponsor Member Author

@isidentical isidentical Mar 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't add a check about underlying code object because I think we should compare the bytecode not the source but I'm OK to change it if needed?

>>> dis.Bytecode("print(1)") == dis.Bytecode(compile("print(1)", "<stdin>", "eval"))
True
>>> dis.Bytecode("print(1)")._original_object == dis.Bytecode(compile("print(1)", "<stdin>", "eval"))._original_object
False

Doc/whatsnew/3.9.rst Outdated Show resolved Hide resolved
@isidentical
Copy link
Sponsor Member Author

isidentical commented May 17, 2020

@serhiy-storchaka any suggestion / thought about the subject?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants