Skip to content

A tool to compare Python files at the bytecode level.#23120

Closed
gpshead wants to merge 2 commits intopython:masterfrom
gpshead:compare_code_logic
Closed

A tool to compare Python files at the bytecode level.#23120
gpshead wants to merge 2 commits intopython:masterfrom
gpshead:compare_code_logic

Conversation

@gpshead
Copy link
Member

@gpshead gpshead commented Nov 3, 2020

Comparison is done via generated bytecode. Ignoring non-logic changes such as line numbers and the code filename. This way things like reflowing of implicitly joined string constants pass the test as those do not generate different bytecode. This isn't intended to analyze the logic (there are obviously many ways to emit bytecode that'd have the same logical outcome), just ensure that the same bytecode and data is generated from both source files.

This would be a nice optional step that code transformation tools (yapf, black, darker, autopep8, etc.) could offer to validate their own work.

BPO Issue? To be filed if this is even going to land here (I assume not). This would make sense as its own tool & library on PyPI.

Possible weakness? Reindented multi-line docstrings. I ran into that while writing this with two space indents and using Tools/reindent.py to turn it into four. :/

I'm putting it here for initial review and in support of the automatically formatting the CPython codebase pre-PEP.

Comparison is done via generated bytecode.  Ignores non-logic changes
such as line number changes and the source filename.  This way things
like reflowing of implicitly joined string constants pass the test
as those do not generate different bytecode.

Possible weakness?  Reindented docstrings.
@gpshead
Copy link
Member Author

gpshead commented Nov 3, 2020

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Dec 16, 2020
@gpshead gpshead closed this Dec 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review DO-NOT-MERGE stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants