Micro-optimization: replace s.find(x)!=-1 with x in s

timeit shows a speedup of ~3x on Python 2.7.5 x86_64.
It also makes the code a bit shorter.
This commit is contained in:
Cristian Ciupitu
2014-01-23 17:02:17 +02:00
committed by Michael DeHaan
parent a7da5d8702
commit 0749112286
19 changed files with 50 additions and 48 deletions

View File

@@ -259,7 +259,7 @@ def privileges_unpack(priv):
output = {}
for item in priv.split('/'):
pieces = item.split(':')
if pieces[0].find('.') != -1:
if '.' in pieces[0]:
pieces[0] = pieces[0].split('.')
for idx, piece in enumerate(pieces):
if pieces[0][idx] != "*":