[issue39902] dis.Bytecode objects should be comparable

Steven D'Aprano report at bugs.python.org
Sun Mar 8 09:32:30 EDT 2020


Steven D'Aprano <steve+python at pearwood.info> added the comment:

What does it mean for two Bytecode objects to be equal?

I know what equality means for ints: they have the same numeric value.

I know what equality means for strings: they have the same sequence of Unicode code points.

I have no concept of what it would mean for two Bytecode objects to be equal or unequal. Your patch compares the tuple:

    (codeobj, first_line, current_offset)

but why do you compare those rather than, say, the source code, or the disassembled byte code, or something else?

Before I read your patch, I guested that you would have defined `__eq__` as `self.dis() == other.dis()`.

----------
nosy: +steven.daprano

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39902>
_______________________________________


More information about the Python-bugs-list mailing list