A tool to compare Python files at the bytecode level.#23120
Closed
gpshead wants to merge 2 commits intopython:masterfrom
Closed
A tool to compare Python files at the bytecode level.#23120gpshead wants to merge 2 commits intopython:masterfrom
gpshead wants to merge 2 commits intopython:masterfrom
Conversation
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.
Member
Author
|
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.