From 7a4270184aeb799a190bcccf19e93aefbcd5a98f Mon Sep 17 00:00:00 2001 From: Cristian Ciupitu Date: Thu, 27 Mar 2014 20:30:09 +0200 Subject: [PATCH] Micro-optimization: replace s.find(x)==0 with s.startswith(x) timeit shows a speedup of ~1.4x on Python 2.7.5 x86_64. It also makes the code a bit shorter. --- system/service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/service b/system/service index 97a970a9515..141b2ac418a 100644 --- a/system/service +++ b/system/service @@ -1008,7 +1008,7 @@ class SunOSService(Service): # enabled true # enabled false for line in stdout.split("\n"): - if line.find("enabled") == 0: + if line.startswith("enabled"): if "true" in line: enabled = True if "temporary" in line: