[pypy-commit] pypy speedup-list-comprehension: disable the code dump. A bit of progress when and how we emit the correct

fijal noreply at buildbot.pypy.org
Fri Feb 24 03:35:02 CET 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: speedup-list-comprehension
Changeset: r52825:b3406c3e63a4
Date: 2012-02-23 19:20 -0700
http://bitbucket.org/pypy/pypy/changeset/b3406c3e63a4/

Log:	disable the code dump. A bit of progress when and how we emit the
	correct opcode.

diff --git a/pypy/interpreter/astcompiler/codegen.py b/pypy/interpreter/astcompiler/codegen.py
--- a/pypy/interpreter/astcompiler/codegen.py
+++ b/pypy/interpreter/astcompiler/codegen.py
@@ -965,7 +965,7 @@
         self.emit_op_arg(ops.CALL_METHOD, (kwarg_count << 8) | arg_count)
         return True
 
-    def _listcomp_generator(self, gens, gen_index, elt, outermost=False):
+    def _listcomp_generator(self, gens, gen_index, elt, emit_build=False):
         start = self.new_block()
         skip = self.new_block()
         if_cleanup = self.new_block()
@@ -973,7 +973,7 @@
         gen = gens[gen_index]
         assert isinstance(gen, ast.comprehension)
         gen.iter.walkabout(self)
-        if outermost:
+        if emit_build:
             self.emit_op(ops.BUILD_LIST_FROM_ARG)
         self.emit_op(ops.GET_ITER)
         self.use_next_block(start)
@@ -1000,7 +1000,12 @@
 
     def visit_ListComp(self, lc):
         self.update_position(lc.lineno)
-        self._listcomp_generator(lc.generators, 0, lc.elt, outermost=True)
+        if not lc.generators[0].ifs and len(lc.generators) == 1:
+            emit_build = True
+        else:
+            emit_build = False
+            self.emit_op_arg(ops.BUILD_LIST, 0)
+        self._listcomp_generator(lc.generators, 0, lc.elt, emit_build)
 
     def _comp_generator(self, node, generators, gen_index):
         start = self.new_block()
diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py
--- a/pypy/interpreter/pycode.py
+++ b/pypy/interpreter/pycode.py
@@ -4,7 +4,7 @@
 The bytecode interpreter itself is implemented by the PyFrame class.
 """
 
-import dis, imp, struct, types, new, sys
+import imp, struct, types, new, sys, dis
 
 from pypy.interpreter import eval
 from pypy.interpreter.argument import Signature
@@ -14,7 +14,6 @@
     CO_OPTIMIZED, CO_NEWLOCALS, CO_VARARGS, CO_VARKEYWORDS, CO_NESTED,
     CO_GENERATOR, CO_CONTAINSGLOBALS)
 from pypy.rlib.rarithmetic import intmask
-from pypy.rlib.debug import make_sure_not_resized
 from pypy.rlib import jit
 from pypy.rlib.objectmodel import compute_hash
 from pypy.tool.stdlib_opcode import opcodedesc, HAVE_ARGUMENT
@@ -265,6 +264,7 @@
 
     def dump(self):
         """A dis.dis() dump of the code object."""
+        return
         co = self._to_code()
         dis.dis(co)
 


More information about the pypy-commit mailing list