From f825e7ef28c65689e06453d0c3a00310b90cdfdb Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 12 Aug 2020 19:12:21 -0700 Subject: [PATCH 1/1] Remove slow assertion (#1592) 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. --- src/black/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/black/__init__.py b/src/black/__init__.py index 930f2cb..7ce2ac8 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -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) -- 2.39.5