[Piglit] [RFC 06/25] gen_tes_input_tests.py: use six.moves.range

Dylan Baker baker.dylan.c at gmail.com
Wed Oct 7 14:17:07 PDT 2015


This maintains python 2.x and 3.x compatibility, while still using an
efficient iterator function (unlike range in python 2.x which returns a
list)

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 generated_tests/gen_tes_input_tests.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/generated_tests/gen_tes_input_tests.py b/generated_tests/gen_tes_input_tests.py
index bff1c8e..d716ca0 100644
--- a/generated_tests/gen_tes_input_tests.py
+++ b/generated_tests/gen_tes_input_tests.py
@@ -45,6 +45,8 @@ import os
 import sys
 import random
 
+from six.moves import range
+
 
 class Test(object):
     def __init__(self, type_name, array, patch_in, name):
@@ -127,12 +129,12 @@ class Test(object):
         data = self.test_data()
         uniforms = ''
         if self.var_array:
-            for i in xrange(self.reference_size):
-                for j in xrange(self.var_array):
+            for i in range(self.reference_size):
+                for j in range(self.var_array):
                     uniforms += 'uniform {0} reference[{1}].v[{2}] {3}\n'.format(
                         self.var_type, i, j, data[i*j])
         else:
-            for i in xrange(self.reference_size):
+            for i in range(self.reference_size):
                 uniforms += 'uniform {0} reference[{1}].v {2}\n'.format(
                     self.var_type,
                     i,
@@ -183,8 +185,8 @@ class Test(object):
         c = self.components()
 
         ret = []
-        for i in xrange(n):
-            ret.append(" ".join(str(rand()) for _ in xrange(c)))
+        for i in range(n):
+            ret.append(" ".join(str(rand()) for _ in range(c)))
 
         return ret
 
-- 
2.6.0



More information about the Piglit mailing list