[Piglit] [PATCH 2/4] piglit-run.py: Use list.append(item) instead of list[:0] = [item].

Kenneth Graunke kenneth at whitecape.org
Fri Feb 17 01:38:49 PST 2012


list[:0] = [item] is a strange way to add an item to a list.

1. It forces the list to be copied, which can be inefficient.
2. It produces a strange ordering:

   >>> x = [1, 2, 3]
   >>> x[:0] = [4]
   >>> x
   [4, 1, 2, 3]

   ...whereas list.append(item) produces [1, 2, 3, 4].

3. Most importantly, list.append is easier to understand at a glance.

Reported-by: Paul Berry <stereotype441 at gmail.com>
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 piglit-run.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/piglit-run.py b/piglit-run.py
index f67984f..b6f8bf5 100755
--- a/piglit-run.py
+++ b/piglit-run.py
@@ -88,9 +88,9 @@ def main():
 		elif name in ('-d', '--dry-run'):
 			env.execute = False
 		elif name in ('-t', '--tests'):
-			env.filter[:0] = [re.compile(value)]
+			env.filter.append(re.compile(value))
 		elif name in ('-x', '--exclude-tests'):
-			env.exclude_filter[:0] = [re.compile(value)]
+			env.exclude_filter.append(re.compile(value))
 		elif name in ('-n', '--name'):
 			OptionName = value
 		elif name in ('-c, --concurrent'):
-- 
1.7.7.6



More information about the Piglit mailing list