[pypy-commit] pypy default: some random pep8 cleanups
alex_gaynor
noreply at buildbot.pypy.org
Wed Jun 19 23:53:06 CEST 2013
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r64943:2024b065cf2e
Date: 2013-06-19 14:52 -0700
http://bitbucket.org/pypy/pypy/changeset/2024b065cf2e/
Log: some random pep8 cleanups
diff --git a/rpython/jit/metainterp/optimizeopt/generalize.py b/rpython/jit/metainterp/optimizeopt/generalize.py
--- a/rpython/jit/metainterp/optimizeopt/generalize.py
+++ b/rpython/jit/metainterp/optimizeopt/generalize.py
@@ -1,5 +1,6 @@
from rpython.jit.metainterp.optimizeopt.optimizer import MININT, MAXINT
+
class GeneralizationStrategy(object):
def __init__(self, optimizer):
self.optimizer = optimizer
@@ -7,13 +8,13 @@
def apply(self):
raise NotImplementedError
+
class KillHugeIntBounds(GeneralizationStrategy):
def apply(self):
for v in self.optimizer.values.values():
if v.is_constant():
continue
- if v.intbound.lower < MININT/2:
+ if v.intbound.lower < MININT / 2:
v.intbound.lower = MININT
- if v.intbound.upper > MAXINT/2:
+ if v.intbound.upper > MAXINT / 2:
v.intbound.upper = MAXINT
-
diff --git a/rpython/jit/metainterp/optimizeopt/heap.py b/rpython/jit/metainterp/optimizeopt/heap.py
--- a/rpython/jit/metainterp/optimizeopt/heap.py
+++ b/rpython/jit/metainterp/optimizeopt/heap.py
@@ -1,8 +1,8 @@
import os
+from rpython.jit.metainterp.history import Const
from rpython.jit.metainterp.jitexc import JitException
from rpython.jit.metainterp.optimizeopt.optimizer import Optimization, MODE_ARRAY, LEVEL_KNOWNCLASS
-from rpython.jit.metainterp.history import ConstInt, Const
from rpython.jit.metainterp.optimizeopt.util import make_dispatcher_method
from rpython.jit.metainterp.resoperation import rop, ResOperation
from rpython.rlib.objectmodel import we_are_translated
@@ -32,14 +32,14 @@
def do_setfield(self, optheap, op):
# Update the state with the SETFIELD_GC/SETARRAYITEM_GC operation 'op'.
structvalue = optheap.getvalue(op.getarg(0))
- fieldvalue = optheap.getvalue(op.getarglist()[-1])
+ fieldvalue = optheap.getvalue(op.getarglist()[-1])
if self.possible_aliasing(optheap, structvalue):
self.force_lazy_setfield(optheap)
assert not self.possible_aliasing(optheap, structvalue)
cached_fieldvalue = self._cached_fields.get(structvalue, None)
# Hack to ensure constants are imported from the preamble
- if cached_fieldvalue and fieldvalue.is_constant():
+ if cached_fieldvalue and fieldvalue.is_constant():
optheap.optimizer.ensure_imported(cached_fieldvalue)
cached_fieldvalue = self._cached_fields.get(structvalue, None)
@@ -50,7 +50,7 @@
if not self._lazy_setfield_registered:
optheap._lazy_setfields_and_arrayitems.append(self)
self._lazy_setfield_registered = True
-
+
else:
# this is the case where the pending setfield ends up
# storing precisely the value that is already there,
@@ -100,7 +100,7 @@
# back in the cache: the value of this particular structure's
# field.
structvalue = optheap.getvalue(op.getarg(0))
- fieldvalue = optheap.getvalue(op.getarglist()[-1])
+ fieldvalue = optheap.getvalue(op.getarglist()[-1])
self.remember_field_value(structvalue, fieldvalue, op)
elif not can_cache:
self.clear()
@@ -403,7 +403,6 @@
#
cf = self.field_cache(op.getdescr())
cf.do_setfield(self, op)
-
def optimize_GETARRAYITEM_GC(self, op):
arrayvalue = self.getvalue(op.getarg(0))
diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py
--- a/rpython/jit/metainterp/optimizeopt/intbounds.py
+++ b/rpython/jit/metainterp/optimizeopt/intbounds.py
@@ -1,13 +1,12 @@
import sys
-from rpython.jit.metainterp.optimizeopt.optimizer import Optimization, CONST_1, CONST_0, \
- MODE_ARRAY, MODE_STR, MODE_UNICODE
from rpython.jit.metainterp.history import ConstInt
+from rpython.jit.metainterp.optimize import InvalidLoop
from rpython.jit.metainterp.optimizeopt.intutils import (IntBound, IntLowerBound,
IntUpperBound)
+from rpython.jit.metainterp.optimizeopt.optimizer import (Optimization, CONST_1,
+ CONST_0, MODE_ARRAY, MODE_STR, MODE_UNICODE)
from rpython.jit.metainterp.optimizeopt.util import make_dispatcher_method
from rpython.jit.metainterp.resoperation import rop
-from rpython.jit.metainterp.optimize import InvalidLoop
-from rpython.rlib.rarithmetic import LONG_BIT
class OptIntBounds(Optimization):
@@ -24,7 +23,6 @@
assert not op.is_ovf()
self.emit_operation(op)
-
def propagate_bounds_backward(self, box):
# FIXME: This takes care of the instruction where box is the reuslt
# but the bounds produced by all instructions where box is
@@ -68,11 +66,11 @@
if v2.is_constant():
val = v2.box.getint()
if val >= 0:
- r.intbound.intersect(IntBound(0,val))
+ r.intbound.intersect(IntBound(0, val))
elif v1.is_constant():
val = v1.box.getint()
if val >= 0:
- r.intbound.intersect(IntBound(0,val))
+ r.intbound.intersect(IntBound(0, val))
def optimize_INT_SUB(self, op):
v1 = self.getvalue(op.getarg(0))
@@ -111,7 +109,7 @@
def optimize_INT_MOD(self, op):
v1 = self.getvalue(op.getarg(0))
v2 = self.getvalue(op.getarg(1))
- known_nonneg = (v1.intbound.known_ge(IntBound(0, 0)) and
+ known_nonneg = (v1.intbound.known_ge(IntBound(0, 0)) and
v2.intbound.known_ge(IntBound(0, 0)))
if known_nonneg and v2.is_constant():
val = v2.box.getint()
@@ -197,7 +195,7 @@
if opnum not in (rop.INT_ADD_OVF, rop.INT_SUB_OVF, rop.INT_MUL_OVF):
raise InvalidLoop('An INT_xxx_OVF was proven not to overflow but' +
'guarded with GUARD_OVERFLOW')
-
+
self.emit_operation(op)
def optimize_INT_ADD_OVF(self, op):
@@ -299,7 +297,7 @@
def optimize_ARRAYLEN_GC(self, op):
self.emit_operation(op)
- array = self.getvalue(op.getarg(0))
+ array = self.getvalue(op.getarg(0))
result = self.getvalue(op.result)
array.make_len_gt(MODE_ARRAY, op.getdescr(), -1)
array.lenbound.bound.intersect(result.intbound)
@@ -307,7 +305,7 @@
def optimize_STRLEN(self, op):
self.emit_operation(op)
- array = self.getvalue(op.getarg(0))
+ array = self.getvalue(op.getarg(0))
result = self.getvalue(op.result)
array.make_len_gt(MODE_STR, op.getdescr(), -1)
array.lenbound.bound.intersect(result.intbound)
@@ -315,7 +313,7 @@
def optimize_UNICODELEN(self, op):
self.emit_operation(op)
- array = self.getvalue(op.getarg(0))
+ array = self.getvalue(op.getarg(0))
result = self.getvalue(op.result)
array.make_len_gt(MODE_UNICODE, op.getdescr(), -1)
array.lenbound.bound.intersect(result.intbound)
@@ -470,9 +468,9 @@
if v1.intbound.intersect(b):
self.propagate_bounds_backward(op.getarg(0))
- propagate_bounds_INT_ADD_OVF = propagate_bounds_INT_ADD
- propagate_bounds_INT_SUB_OVF = propagate_bounds_INT_SUB
- propagate_bounds_INT_MUL_OVF = propagate_bounds_INT_MUL
+ propagate_bounds_INT_ADD_OVF = propagate_bounds_INT_ADD
+ propagate_bounds_INT_SUB_OVF = propagate_bounds_INT_SUB
+ propagate_bounds_INT_MUL_OVF = propagate_bounds_INT_MUL
dispatch_opt = make_dispatcher_method(OptIntBounds, 'optimize_',
More information about the pypy-commit
mailing list