[pypy-commit] pypy python-loop-unroll: deadcode + pep8

alex_gaynor noreply at buildbot.pypy.org
Wed May 29 00:51:07 CEST 2013


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: python-loop-unroll
Changeset: r64652:c4ba4835f87a
Date: 2013-05-28 15:50 -0700
http://bitbucket.org/pypy/pypy/changeset/c4ba4835f87a/

Log:	deadcode + pep8

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
@@ -11,7 +11,6 @@
 from pypy.interpreter.astcompiler import optimize # For side effects
 from pypy.interpreter.pyparser.error import SyntaxError
 from pypy.tool import stdlib_opcode as ops
-from pypy.interpreter.error import OperationError
 
 
 def compile_ast(space, module, info):
@@ -21,91 +20,91 @@
 
 
 name_ops_default = misc.dict_to_switch({
-    ast.Load : ops.LOAD_NAME,
-    ast.Store : ops.STORE_NAME,
-    ast.Del : ops.DELETE_NAME
+    ast.Load: ops.LOAD_NAME,
+    ast.Store: ops.STORE_NAME,
+    ast.Del: ops.DELETE_NAME
 })
 
 name_ops_fast = misc.dict_to_switch({
-    ast.Load : ops.LOAD_FAST,
-    ast.Store : ops.STORE_FAST,
-    ast.Del : ops.DELETE_FAST
+    ast.Load: ops.LOAD_FAST,
+    ast.Store: ops.STORE_FAST,
+    ast.Del: ops.DELETE_FAST
 })
 
 name_ops_deref = misc.dict_to_switch({
-    ast.Load : ops.LOAD_DEREF,
-    ast.Store : ops.STORE_DEREF,
+    ast.Load: ops.LOAD_DEREF,
+    ast.Store: ops.STORE_DEREF,
 })
 
 name_ops_global = misc.dict_to_switch({
-    ast.Load : ops.LOAD_GLOBAL,
-    ast.Store : ops.STORE_GLOBAL,
-    ast.Del : ops.DELETE_GLOBAL
+    ast.Load: ops.LOAD_GLOBAL,
+    ast.Store: ops.STORE_GLOBAL,
+    ast.Del: ops.DELETE_GLOBAL
 })
 
 
 unary_operations = misc.dict_to_switch({
-    ast.Invert : ops.UNARY_INVERT,
-    ast.Not : ops.UNARY_NOT,
-    ast.UAdd : ops.UNARY_POSITIVE,
-    ast.USub : ops.UNARY_NEGATIVE
+    ast.Invert: ops.UNARY_INVERT,
+    ast.Not: ops.UNARY_NOT,
+    ast.UAdd: ops.UNARY_POSITIVE,
+    ast.USub: ops.UNARY_NEGATIVE
 })
 
 binary_operations = misc.dict_to_switch({
-    ast.Add : ops.BINARY_ADD,
-    ast.Sub : ops.BINARY_SUBTRACT,
-    ast.Mult : ops.BINARY_MULTIPLY,
-    ast.Mod : ops.BINARY_MODULO,
-    ast.Pow : ops.BINARY_POWER,
-    ast.LShift : ops.BINARY_LSHIFT,
-    ast.RShift : ops.BINARY_RSHIFT,
-    ast.BitOr : ops.BINARY_OR,
-    ast.BitAnd : ops.BINARY_AND,
-    ast.BitXor : ops.BINARY_XOR,
-    ast.FloorDiv : ops.BINARY_FLOOR_DIVIDE
+    ast.Add: ops.BINARY_ADD,
+    ast.Sub: ops.BINARY_SUBTRACT,
+    ast.Mult: ops.BINARY_MULTIPLY,
+    ast.Mod: ops.BINARY_MODULO,
+    ast.Pow: ops.BINARY_POWER,
+    ast.LShift: ops.BINARY_LSHIFT,
+    ast.RShift: ops.BINARY_RSHIFT,
+    ast.BitOr: ops.BINARY_OR,
+    ast.BitAnd: ops.BINARY_AND,
+    ast.BitXor: ops.BINARY_XOR,
+    ast.FloorDiv: ops.BINARY_FLOOR_DIVIDE
 })
 
 inplace_operations = misc.dict_to_switch({
-    ast.Add : ops.INPLACE_ADD,
-    ast.Sub : ops.INPLACE_SUBTRACT,
-    ast.Mult : ops.INPLACE_MULTIPLY,
-    ast.Mod : ops.INPLACE_MODULO,
-    ast.Pow : ops.INPLACE_POWER,
-    ast.LShift : ops.INPLACE_LSHIFT,
-    ast.RShift : ops.INPLACE_RSHIFT,
-    ast.BitOr : ops.INPLACE_OR,
-    ast.BitAnd : ops.INPLACE_AND,
-    ast.BitXor : ops.INPLACE_XOR,
-    ast.FloorDiv : ops.INPLACE_FLOOR_DIVIDE
+    ast.Add: ops.INPLACE_ADD,
+    ast.Sub: ops.INPLACE_SUBTRACT,
+    ast.Mult: ops.INPLACE_MULTIPLY,
+    ast.Mod: ops.INPLACE_MODULO,
+    ast.Pow: ops.INPLACE_POWER,
+    ast.LShift: ops.INPLACE_LSHIFT,
+    ast.RShift: ops.INPLACE_RSHIFT,
+    ast.BitOr: ops.INPLACE_OR,
+    ast.BitAnd: ops.INPLACE_AND,
+    ast.BitXor: ops.INPLACE_XOR,
+    ast.FloorDiv: ops.INPLACE_FLOOR_DIVIDE
 })
 
 compare_operations = misc.dict_to_switch({
-    ast.Eq : 2,
-    ast.NotEq : 3,
-    ast.Lt : 0,
-    ast.LtE : 1,
-    ast.Gt : 4,
-    ast.GtE : 5,
-    ast.In : 6,
-    ast.NotIn : 7,
-    ast.Is : 8,
-    ast.IsNot : 9
+    ast.Eq: 2,
+    ast.NotEq: 3,
+    ast.Lt: 0,
+    ast.LtE: 1,
+    ast.Gt: 4,
+    ast.GtE: 5,
+    ast.In: 6,
+    ast.NotIn: 7,
+    ast.Is: 8,
+    ast.IsNot: 9
 })
 
 subscr_operations = misc.dict_to_switch({
-    ast.AugLoad : ops.BINARY_SUBSCR,
-    ast.Load : ops.BINARY_SUBSCR,
-    ast.AugStore : ops.STORE_SUBSCR,
-    ast.Store : ops.STORE_SUBSCR,
-    ast.Del : ops.DELETE_SUBSCR
+    ast.AugLoad: ops.BINARY_SUBSCR,
+    ast.Load: ops.BINARY_SUBSCR,
+    ast.AugStore: ops.STORE_SUBSCR,
+    ast.Store: ops.STORE_SUBSCR,
+    ast.Del: ops.DELETE_SUBSCR
 })
 
 slice_operations = misc.dict_to_switch({
-    ast.AugLoad : ops.SLICE,
-    ast.Load : ops.SLICE,
-    ast.AugStore : ops.STORE_SLICE,
-    ast.Store : ops.STORE_SLICE,
-    ast.Del : ops.DELETE_SLICE
+    ast.AugLoad: ops.SLICE,
+    ast.Load: ops.SLICE,
+    ast.AugStore: ops.STORE_SLICE,
+    ast.Store: ops.STORE_SLICE,
+    ast.Del: ops.DELETE_SLICE
 })
 
 
@@ -475,9 +474,8 @@
                     self.emit_jump(ops.CONTINUE_LOOP, block, True)
                     break
                 if f_type == F_BLOCK_FINALLY_END:
-                    self.error("'continue' not supported inside 'finally' " \
-                                   "clause",
-                               cont)
+                    self.error("'continue' not supported inside 'finally' "
+                                   "clause", cont)
             else:
                 self.error("'continue' not properly in loop", cont)
         elif current_block == F_BLOCK_FINALLY_END:
@@ -637,7 +635,7 @@
             last_line, last_offset = self.compile_info.last_future_import
             if imp.lineno > last_line or \
                     imp.lineno == last_line and imp.col_offset > last_offset:
-                self.error("__future__ statements must appear at beginning " \
+                self.error("__future__ statements must appear at beginning "
                                "of file", imp)
             if star_import:
                 self.error("* not valid in __future__ imports", imp)
@@ -816,7 +814,6 @@
 
     def visit_Const(self, const):
         self.update_position(const.lineno)
-        space = self.space
         self.load_const(const.value)
 
     def visit_UnaryOp(self, op):
@@ -975,7 +972,7 @@
         elif call_type == 3:
             op = ops.CALL_FUNCTION_VAR_KW
         self.emit_op_arg(op, arg)
-    
+
     def _call_has_no_star_args(self, call):
         return not call.starargs and not call.kwargs
 
@@ -1014,12 +1011,9 @@
         self.use_next_block()
         gen.target.walkabout(self)
         if gen.ifs:
-            if_count = len(gen.ifs)
             for if_ in gen.ifs:
                 if_.accept_jump_if(self, False, if_cleanup)
                 self.use_next_block()
-        else:
-            if_count = 0
         gen_index += 1
         if gen_index < len(gens):
             self._listcomp_generator(gens, gen_index, elt)
@@ -1042,7 +1036,6 @@
 
     def _comp_generator(self, node, generators, gen_index):
         start = self.new_block()
-        skip = self.new_block()
         if_cleanup = self.new_block()
         anchor = self.new_block()
         gen = generators[gen_index]
@@ -1058,12 +1051,9 @@
         self.use_next_block()
         gen.target.walkabout(self)
         if gen.ifs:
-            ifs_count = len(gen.ifs)
             for if_ in gen.ifs:
                 if_.accept_jump_if(self, False, if_cleanup)
                 self.use_next_block()
-        else:
-            ifs_count = 0
         gen_index += 1
         if gen_index < len(generators):
             self._comp_generator(node, generators, gen_index)
@@ -1176,22 +1166,18 @@
 
     def _compile_slice(self, slc, ctx):
         if isinstance(slc, ast.Index):
-            kind = "index"
             if ctx != ast.AugStore:
                 slc.value.walkabout(self)
         elif isinstance(slc, ast.Ellipsis):
-            kind = "ellipsis"
             if ctx != ast.AugStore:
                 self.load_const(self.space.w_Ellipsis)
         elif isinstance(slc, ast.Slice):
-            kind = "slice"
             if not slc.step:
                 self._simple_slice(slc, ctx)
                 return
             elif ctx != ast.AugStore:
                 self._complex_slice(slc, ctx)
         elif isinstance(slc, ast.ExtSlice):
-            kind = "extended slice"
             if ctx != ast.AugStore:
                 for dim in slc.dims:
                     self._nested_slice(dim, ctx)


More information about the pypy-commit mailing list