[pypy-svn] r62709 - in pypy/trunk/pypy: rpython/lltypesystem translator/test

arigo at codespeak.net arigo at codespeak.net
Sat Mar 7 15:42:21 CET 2009


Author: arigo
Date: Sat Mar  7 15:42:21 2009
New Revision: 62709

Modified:
   pypy/trunk/pypy/rpython/lltypesystem/rlist.py
   pypy/trunk/pypy/translator/test/test_simplify.py
Log:
Test and fix for list comprehension operations.


Modified: pypy/trunk/pypy/rpython/lltypesystem/rlist.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/rlist.py	(original)
+++ pypy/trunk/pypy/rpython/lltypesystem/rlist.py	Sat Mar  7 15:42:21 2009
@@ -136,10 +136,10 @@
         hints = hop.args_s[-1].const
         if 'maxlength' in hints:
             if optimized:
+                v_iterable = hop.args_v[1]
                 s_iterable = hop.args_s[1]
                 r_iterable = hop.args_r[1]
                 v_list = hop.inputarg(self, arg=0)
-                v_iterable = hop.inputarg(r_iterable, arg=1)
                 hop2 = hop.copy()
                 while hop2.nb_args > 0:
                     hop2.r_s_popfirstarg()

Modified: pypy/trunk/pypy/translator/test/test_simplify.py
==============================================================================
--- pypy/trunk/pypy/translator/test/test_simplify.py	(original)
+++ pypy/trunk/pypy/translator/test/test_simplify.py	Sat Mar  7 15:42:21 2009
@@ -337,6 +337,15 @@
         res = interp.eval_graph(graph, [4, 4])
         assert res == 1 + 4 * 17 + 4 * 17
 
+    def test_iterate_over_constant(self):
+        CONST = range(10)
+        def main(n):
+            lst = [x*17 for x in CONST]
+            return lst[5]
+        interp, graph = self.specialize(main, [int])
+        res = interp.eval_graph(graph, [10])
+        assert res == 5 * 17
+
 ## TODO: maxlength and fence hints are not supported by ootype
 ## see doc/discussion/list_comprehension_ootype.txt
 ##class TestOOSpecializeListComprehension(TestLLSpecializeListComprehension):



More information about the Pypy-commit mailing list