Add dead branch removal - #149
Merged
Merged
Conversation
- Add constant folding for BoolOp and Compare nodes - Add RemoveDeadBranches transform to safely remove dead If branches and in-line the surviving branch, only when it doesn't change program behaviour - Re-write RemoveDebug transform to explicitly mark __debug__ as False, and rely on the dead branch removal to trim it This fixes some problems with the previous RemoveDebug transform: - The whole branch was removed with accounting for how it affects enclosing function symbol table - The else branch would be removed along with the body Also fixes SuiteTransformer not transforming some suites like exception handler blocks.
Show larger than base for all python versions Show time delta for slowest entries.
covering new changes: - bool folding - SuiteTransformer descending into more blocks - RemoveDebug changes - RemoveDeadBranches
Even with a fixed hash seed renaming would vary between runs
Exploring a namespace down to other namespace nodes isn't quite enough, some namespace nodes have child nodes in their parent namespace. The problematic one here is NamedExpr targets inside a comprehension. Also enhances RemoveDeadBranches to fully remove orelse suites if they only consist of the literal zero expression placeholder.
This is through evaluation of minifier internal values - not used fixable. When DeprecationWarnings become errors (through interpreter options, or future Python versions), then it'll just stop folding. Until then we can do it, just swallow the warning.
It generates a DeprecationWarning since 3.12
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.
This fixes some problems with the previous RemoveDebug transform:
Also fixes SuiteTransformer not transforming some suites like exception handler blocks.