Skip to content

Commit

Permalink
Remove slow assertion (#1592)
Browse files Browse the repository at this point in the history
Partial fix for #1581

This assertion produces behavior quadratic in the number of leaves in a line, which is making Black extremely slow on files with very long expressions. On my benchmark file this change makes Black 10x faster.
  • Loading branch information
JelleZijlstra authored Aug 13, 2020
1 parent b59a524 commit f825e7e
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/black/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4594,8 +4594,6 @@ def append_leaves(new_line: Line, old_line: Line, leaves: List[Leaf]) -> None:
set(@leaves) is a subset of set(@old_line.leaves).
"""
for old_leaf in leaves:
assert old_leaf in old_line.leaves

new_leaf = Leaf(old_leaf.type, old_leaf.value)
replace_child(old_leaf, new_leaf)
new_line.append(new_leaf)
Expand Down

0 comments on commit f825e7e

Please sign in to comment.