Skip to content

Commit

Permalink
Replace remove with list comprehension on sql.py
Browse files Browse the repository at this point in the history
Help performance for #62, #135
  • Loading branch information
vmuriart committed Jun 11, 2016
1 parent 9989792 commit 50de51a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sqlparse/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ def group_tokens(self, grp_cls, tokens, skip_ws=False, extend=False):

for token in tokens:
token.parent = grp
self.tokens.remove(token)

# Improve performance. LOOP(list.remove()) is O(n**2) operation
self.tokens = [token for token in self.tokens if token not in tokens]

self.tokens.insert(idx, grp)
grp.parent = self
Expand Down

1 comment on commit 50de51a

@vmuriart
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.