Permalink
Browse files

.startswith()/.endswith() are faster than .find().

  • Loading branch information...
1 parent 8684a6f commit d6bc8c187d3cf7f60d2479c2da024a384a756c92 @alecthomas alecthomas committed with florentx Aug 16, 2010
Showing with 2 additions and 2 deletions.
  1. +2 −2 pep8.py
View
@@ -411,9 +411,9 @@ def whitespace_around_operator(logical_line):
if operator not in OPERATORS:
continue
offset = match.start()
- if text.find(' ' + operator) != -1:
+ if text.startswith(' '):
return offset, "E221 multiple spaces before operator"
- if text.find(operator + ' ') != -1:
+ if text.endswith(' '):
return offset, "E222 multiple spaces after operator"
if text.find('\t' + operator) != -1:
return offset, "E223 tab before operator"

0 comments on commit d6bc8c1

Please sign in to comment.