[pypy-commit] pypy default: merge heads

arigo noreply at buildbot.pypy.org
Wed Jan 22 10:36:47 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r68839:7f07524f0084
Date: 2014-01-22 10:35 +0100
http://bitbucket.org/pypy/pypy/changeset/7f07524f0084/

Log:	merge heads

diff too long, truncating to 2000 out of 3801 lines

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -48,3 +48,7 @@
 .. branch: remove-del-from-generatoriterator
 Speed up generators that don't yield inside try or wait blocks by skipping
 unnecessary cleanup.
+
+.. branch: annotator
+Remove FlowObjSpace.
+Improve cohesion between rpython.flowspace and rpython.annotator.
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -910,7 +910,7 @@
         """
         return self.unpackiterable(w_iterable, expected_length)
 
-    def listview_str(self, w_list):
+    def listview_bytes(self, w_list):
         """ Return a list of unwrapped strings out of a list of strings. If the
         argument is not a list or does not contain only strings, return None.
         May return None anyway.
@@ -944,7 +944,7 @@
         """
         return (None, None)
 
-    def newlist_str(self, list_s):
+    def newlist_bytes(self, list_s):
         return self.newlist([self.wrap(s) for s in list_s])
 
     def newlist_unicode(self, list_u):
diff --git a/pypy/module/__pypy__/test/test_special.py b/pypy/module/__pypy__/test/test_special.py
--- a/pypy/module/__pypy__/test/test_special.py
+++ b/pypy/module/__pypy__/test/test_special.py
@@ -51,7 +51,9 @@
         l = [1, 2, 3]
         assert list_strategy(l) == "int"
         l = ["a", "b", "c"]
-        assert list_strategy(l) == "str"
+        assert list_strategy(l) == "bytes"
+        l = [u"a", u"b", u"c"]
+        assert list_strategy(l) == "unicode"
         l = [1.1, 2.2, 3.3]
         assert list_strategy(l) == "float"
         l = range(3)
diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py
--- a/pypy/module/cpyext/test/test_cpyext.py
+++ b/pypy/module/cpyext/test/test_cpyext.py
@@ -213,12 +213,14 @@
             Build an extension module linked against the cpyext api library.
             """
             if not space.is_none(w_separate_module_files):
-                separate_module_files = space.listview_str(w_separate_module_files)
+                separate_module_files = space.listview_bytes(
+                    w_separate_module_files)
                 assert separate_module_files is not None
             else:
                 separate_module_files = []
             if not space.is_none(w_separate_module_sources):
-                separate_module_sources = space.listview_str(w_separate_module_sources)
+                separate_module_sources = space.listview_bytes(
+                    w_separate_module_sources)
                 assert separate_module_sources is not None
             else:
                 separate_module_sources = []
diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -441,8 +441,8 @@
     def str_w(self, space):
         return self._value
 
-    def listview_str(self):
-        return _create_list_from_string(self._value)
+    def listview_bytes(self):
+        return _create_list_from_bytes(self._value)
 
     def ord(self, space):
         if len(self._value) != 1:
@@ -518,7 +518,7 @@
     _title = _upper
 
     def _newlist_unwrapped(self, space, lst):
-        return space.newlist_str(lst)
+        return space.newlist_bytes(lst)
 
     @staticmethod
     @unwrap_spec(w_object = WrappedDefault(""))
@@ -725,9 +725,9 @@
         return tformat.formatter_field_name_split()
 
 
-def _create_list_from_string(value):
+def _create_list_from_bytes(value):
     # need this helper function to allow the jit to look inside and inline
-    # listview_str
+    # listview_bytes
     return [s for s in value]
 
 W_BytesObject.EMPTY = W_BytesObject('')
diff --git a/pypy/objspace/std/celldict.py b/pypy/objspace/std/celldict.py
--- a/pypy/objspace/std/celldict.py
+++ b/pypy/objspace/std/celldict.py
@@ -127,7 +127,7 @@
     def w_keys(self, w_dict):
         space = self.space
         l = self.unerase(w_dict.dstorage).keys()
-        return space.newlist_str(l)
+        return space.newlist_bytes(l)
 
     def values(self, w_dict):
         iterator = self.unerase(w_dict.dstorage).itervalues
diff --git a/pypy/objspace/std/dictmultiobject.py b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -58,7 +58,7 @@
             strategy = space.fromcache(MapDictStrategy)
         elif instance or strdict or module:
             assert w_type is None
-            strategy = space.fromcache(StringDictStrategy)
+            strategy = space.fromcache(BytesDictStrategy)
         elif kwargs:
             assert w_type is None
             from pypy.objspace.std.kwargsdict import EmptyKwargsDictStrategy
@@ -117,9 +117,9 @@
         if space.is_w(w_type, space.w_dict):
             w_dict = W_DictMultiObject.allocate_and_init_instance(space, w_type)
 
-            strlist = space.listview_str(w_keys)
-            if strlist is not None:
-                for key in strlist:
+            byteslist = space.listview_bytes(w_keys)
+            if byteslist is not None:
+                for key in byteslist:
                     w_dict.setitem_str(key, w_fill)
             else:
                 for w_key in space.listview(w_keys):
@@ -333,7 +333,7 @@
                     popitem delitem clear \
                     length w_keys values items \
                     iterkeys itervalues iteritems \
-                    listview_str listview_unicode listview_int \
+                    listview_bytes listview_unicode listview_int \
                     view_as_kwargs".split()
 
     def make_method(method):
@@ -482,7 +482,7 @@
         w_dict.strategy = strategy
         w_dict.dstorage = storage
 
-    def listview_str(self, w_dict):
+    def listview_bytes(self, w_dict):
         return None
 
     def listview_unicode(self, w_dict):
@@ -506,7 +506,7 @@
     def switch_to_correct_strategy(self, w_dict, w_key):
         withidentitydict = self.space.config.objspace.std.withidentitydict
         if type(w_key) is self.space.StringObjectCls:
-            self.switch_to_string_strategy(w_dict)
+            self.switch_to_bytes_strategy(w_dict)
             return
         elif type(w_key) is self.space.UnicodeObjectCls:
             self.switch_to_unicode_strategy(w_dict)
@@ -519,8 +519,8 @@
         else:
             self.switch_to_object_strategy(w_dict)
 
-    def switch_to_string_strategy(self, w_dict):
-        strategy = self.space.fromcache(StringDictStrategy)
+    def switch_to_bytes_strategy(self, w_dict):
+        strategy = self.space.fromcache(BytesDictStrategy)
         storage = strategy.get_empty_storage()
         w_dict.strategy = strategy
         w_dict.dstorage = storage
@@ -572,7 +572,7 @@
         w_dict.setitem(w_key, w_value)
 
     def setitem_str(self, w_dict, key, w_value):
-        self.switch_to_string_strategy(w_dict)
+        self.switch_to_bytes_strategy(w_dict)
         w_dict.setitem_str(key, w_value)
 
     def delitem(self, w_dict, w_key):
@@ -874,8 +874,8 @@
 create_iterator_classes(ObjectDictStrategy)
 
 
-class StringDictStrategy(AbstractTypedStrategy, DictStrategy):
-    erase, unerase = rerased.new_erasing_pair("string")
+class BytesDictStrategy(AbstractTypedStrategy, DictStrategy):
+    erase, unerase = rerased.new_erasing_pair("bytes")
     erase = staticmethod(erase)
     unerase = staticmethod(unerase)
 
@@ -913,11 +913,11 @@
         assert key is not None
         return self.unerase(w_dict.dstorage).get(key, None)
 
-    def listview_str(self, w_dict):
+    def listview_bytes(self, w_dict):
         return self.unerase(w_dict.dstorage).keys()
 
     def w_keys(self, w_dict):
-        return self.space.newlist_str(self.listview_str(w_dict))
+        return self.space.newlist_bytes(self.listview_bytes(w_dict))
 
     def wrapkey(space, key):
         return space.wrap(key)
@@ -935,7 +935,7 @@
             i += 1
         return keys, values
 
-create_iterator_classes(StringDictStrategy)
+create_iterator_classes(BytesDictStrategy)
 
 
 class UnicodeDictStrategy(AbstractTypedStrategy, DictStrategy):
@@ -961,7 +961,7 @@
     def _never_equal_to(self, w_lookup_type):
         return _never_equal_to_string(self.space, w_lookup_type)
 
-    # we should implement the same shortcuts as we do for StringDictStrategy
+    # we should implement the same shortcuts as we do for BytesDictStrategy
 
     ## def setitem_str(self, w_dict, key, w_value):
     ##     assert key is not None
@@ -983,7 +983,7 @@
         return self.unerase(w_dict.dstorage).keys()
 
     ## def w_keys(self, w_dict):
-    ##     return self.space.newlist_str(self.listview_str(w_dict))
+    ##     return self.space.newlist_bytes(self.listview_bytes(w_dict))
 
     def wrapkey(space, key):
         return space.wrap(key)
diff --git a/pypy/objspace/std/dictproxyobject.py b/pypy/objspace/std/dictproxyobject.py
--- a/pypy/objspace/std/dictproxyobject.py
+++ b/pypy/objspace/std/dictproxyobject.py
@@ -84,7 +84,7 @@
 
     def w_keys(self, w_dict):
         space = self.space
-        return space.newlist_str(self.unerase(w_dict.dstorage).dict_w.keys())
+        return space.newlist_bytes(self.unerase(w_dict.dstorage).dict_w.keys())
 
     def values(self, w_dict):
         return [unwrap_cell(self.space, w_value) for w_value in self.unerase(w_dict.dstorage).dict_w.itervalues()]
diff --git a/pypy/objspace/std/kwargsdict.py b/pypy/objspace/std/kwargsdict.py
--- a/pypy/objspace/std/kwargsdict.py
+++ b/pypy/objspace/std/kwargsdict.py
@@ -2,15 +2,13 @@
 ## dict strategy (see dictmultiobject.py)
 
 from rpython.rlib import rerased, jit
-from pypy.objspace.std.dictmultiobject import (DictStrategy,
-                                               create_iterator_classes,
-                                               EmptyDictStrategy,
-                                               ObjectDictStrategy,
-                                               StringDictStrategy)
+from pypy.objspace.std.dictmultiobject import (
+    BytesDictStrategy, DictStrategy, EmptyDictStrategy, ObjectDictStrategy,
+    create_iterator_classes)
 
 
 class EmptyKwargsDictStrategy(EmptyDictStrategy):
-    def switch_to_string_strategy(self, w_dict):
+    def switch_to_bytes_strategy(self, w_dict):
         strategy = self.space.fromcache(KwargsDictStrategy)
         storage = strategy.get_empty_storage()
         w_dict.strategy = strategy
@@ -61,7 +59,7 @@
         else:
             # limit the size so that the linear searches don't become too long
             if len(keys) >= 16:
-                self.switch_to_string_strategy(w_dict)
+                self.switch_to_bytes_strategy(w_dict)
                 w_dict.setitem_str(key, w_value)
             else:
                 keys.append(key)
@@ -111,7 +109,7 @@
 
     def w_keys(self, w_dict):
         l = self.unerase(w_dict.dstorage)[0]
-        return self.space.newlist_str(l[:])
+        return self.space.newlist_bytes(l[:])
 
     def values(self, w_dict):
         return self.unerase(w_dict.dstorage)[1][:] # to make non-resizable
@@ -142,8 +140,8 @@
         w_dict.strategy = strategy
         w_dict.dstorage = strategy.erase(d_new)
 
-    def switch_to_string_strategy(self, w_dict):
-        strategy = self.space.fromcache(StringDictStrategy)
+    def switch_to_bytes_strategy(self, w_dict):
+        strategy = self.space.fromcache(BytesDictStrategy)
         keys, values_w = self.unerase(w_dict.dstorage)
         storage = strategy.get_empty_storage()
         d_new = strategy.unerase(storage)
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -81,7 +81,7 @@
         if not type(w_obj) is W_BytesObject:
             break
     else:
-        return space.fromcache(StringListStrategy)
+        return space.fromcache(BytesListStrategy)
 
     # check for unicode
     for w_obj in list_w:
@@ -162,8 +162,8 @@
         return self
 
     @staticmethod
-    def newlist_str(space, list_s):
-        strategy = space.fromcache(StringListStrategy)
+    def newlist_bytes(space, list_s):
+        strategy = space.fromcache(BytesListStrategy)
         storage = strategy.erase(list_s)
         return W_ListObject.from_storage_and_strategy(space, storage, strategy)
 
@@ -278,10 +278,10 @@
         ObjectListStrategy."""
         return self.strategy.getitems_copy(self)
 
-    def getitems_str(self):
+    def getitems_bytes(self):
         """Return the items in the list as unwrapped strings. If the list does
         not use the list strategy, return None."""
-        return self.strategy.getitems_str(self)
+        return self.strategy.getitems_bytes(self)
 
     def getitems_unicode(self):
         """Return the items in the list as unwrapped unicodes. If the list does
@@ -753,7 +753,7 @@
     def getitems_copy(self, w_list):
         raise NotImplementedError
 
-    def getitems_str(self, w_list):
+    def getitems_bytes(self, w_list):
         return None
 
     def getitems_unicode(self, w_list):
@@ -897,7 +897,7 @@
         if type(w_item) is W_IntObject:
             strategy = self.space.fromcache(IntegerListStrategy)
         elif type(w_item) is W_BytesObject:
-            strategy = self.space.fromcache(StringListStrategy)
+            strategy = self.space.fromcache(BytesListStrategy)
         elif type(w_item) is W_UnicodeObject:
             strategy = self.space.fromcache(UnicodeListStrategy)
         elif type(w_item) is W_FloatObject:
@@ -962,11 +962,11 @@
             w_list.lstorage = strategy.erase(floatlist)
             return
 
-        strlist = space.listview_str(w_iterable)
-        if strlist is not None:
-            w_list.strategy = strategy = space.fromcache(StringListStrategy)
+        byteslist = space.listview_bytes(w_iterable)
+        if byteslist is not None:
+            w_list.strategy = strategy = space.fromcache(BytesListStrategy)
             # need to copy because intlist can share with w_iterable
-            w_list.lstorage = strategy.erase(strlist[:])
+            w_list.lstorage = strategy.erase(byteslist[:])
             return
 
         unilist = space.listview_unicode(w_iterable)
@@ -1592,11 +1592,11 @@
         return self.unerase(w_list.lstorage)
 
 
-class StringListStrategy(ListStrategy):
+class BytesListStrategy(ListStrategy):
     import_from_mixin(AbstractUnwrappedStrategy)
 
     _none_value = None
-    _applevel_repr = "str"
+    _applevel_repr = "bytes"
 
     def wrap(self, stringval):
         return self.space.wrap(stringval)
@@ -1604,7 +1604,7 @@
     def unwrap(self, w_string):
         return self.space.str_w(w_string)
 
-    erase, unerase = rerased.new_erasing_pair("string")
+    erase, unerase = rerased.new_erasing_pair("bytes")
     erase = staticmethod(erase)
     unerase = staticmethod(unerase)
 
@@ -1612,7 +1612,7 @@
         return type(w_obj) is W_BytesObject
 
     def list_is_correct_type(self, w_list):
-        return w_list.strategy is self.space.fromcache(StringListStrategy)
+        return w_list.strategy is self.space.fromcache(BytesListStrategy)
 
     def sort(self, w_list, reverse):
         l = self.unerase(w_list.lstorage)
@@ -1621,7 +1621,7 @@
         if reverse:
             l.reverse()
 
-    def getitems_str(self, w_list):
+    def getitems_bytes(self, w_list):
         return self.unerase(w_list.lstorage)
 
 
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -700,7 +700,7 @@
         self.delitem(w_dict, w_key)
         return (w_key, w_value)
 
-    # XXX could implement a more efficient w_keys based on space.newlist_str
+    # XXX could implement a more efficient w_keys based on space.newlist_bytes
 
     def iterkeys(self, w_dict):
         return MapDictIteratorKeys(self.space, self, w_dict)
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -292,8 +292,8 @@
         assert not list_w or sizehint == -1
         return W_ListObject(self, list_w, sizehint)
 
-    def newlist_str(self, list_s):
-        return W_ListObject.newlist_str(self, list_s)
+    def newlist_bytes(self, list_s):
+        return W_ListObject.newlist_bytes(self, list_s)
 
     def newlist_unicode(self, list_u):
         return W_ListObject.newlist_unicode(self, list_u)
@@ -431,19 +431,19 @@
             raise self._wrap_expected_length(expected_length, len(t))
         return t
 
-    def listview_str(self, w_obj):
+    def listview_bytes(self, w_obj):
         # note: uses exact type checking for objects with strategies,
         # and isinstance() for others.  See test_listobject.test_uses_custom...
         if type(w_obj) is W_ListObject:
-            return w_obj.getitems_str()
+            return w_obj.getitems_bytes()
         if type(w_obj) is W_DictMultiObject:
-            return w_obj.listview_str()
+            return w_obj.listview_bytes()
         if type(w_obj) is W_SetObject or type(w_obj) is W_FrozensetObject:
-            return w_obj.listview_str()
+            return w_obj.listview_bytes()
         if isinstance(w_obj, W_BytesObject) and self._uses_no_iter(w_obj):
-            return w_obj.listview_str()
+            return w_obj.listview_bytes()
         if isinstance(w_obj, W_ListObject) and self._uses_list_iter(w_obj):
-            return w_obj.getitems_str()
+            return w_obj.getitems_bytes()
         return None
 
     def listview_unicode(self, w_obj):
diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -79,9 +79,9 @@
         """ Returns a dict with all elements of the set. Needed only for switching to ObjectSetStrategy. """
         return self.strategy.getdict_w(self)
 
-    def listview_str(self):
+    def listview_bytes(self):
         """ If this is a string set return its contents as a list of uwnrapped strings. Otherwise return None. """
-        return self.strategy.listview_str(self)
+        return self.strategy.listview_bytes(self)
 
     def listview_unicode(self):
         """ If this is a unicode set return its contents as a list of uwnrapped unicodes. Otherwise return None. """
@@ -669,7 +669,7 @@
         """ Returns an empty storage (erased) object. Used to initialize an empty set."""
         raise NotImplementedError
 
-    def listview_str(self, w_set):
+    def listview_bytes(self, w_set):
         return None
 
     def listview_unicode(self, w_set):
@@ -776,7 +776,7 @@
         if type(w_key) is W_IntObject:
             strategy = self.space.fromcache(IntegerSetStrategy)
         elif type(w_key) is W_BytesObject:
-            strategy = self.space.fromcache(StringSetStrategy)
+            strategy = self.space.fromcache(BytesSetStrategy)
         elif type(w_key) is W_UnicodeObject:
             strategy = self.space.fromcache(UnicodeSetStrategy)
         elif self.space.type(w_key).compares_by_identity():
@@ -1196,8 +1196,8 @@
         return self.wrap(result[0])
 
 
-class StringSetStrategy(AbstractUnwrappedSetStrategy, SetStrategy):
-    erase, unerase = rerased.new_erasing_pair("string")
+class BytesSetStrategy(AbstractUnwrappedSetStrategy, SetStrategy):
+    erase, unerase = rerased.new_erasing_pair("bytes")
     erase = staticmethod(erase)
     unerase = staticmethod(unerase)
 
@@ -1207,7 +1207,7 @@
     def get_empty_dict(self):
         return {}
 
-    def listview_str(self, w_set):
+    def listview_bytes(self, w_set):
         return self.unerase(w_set.sstorage).keys()
 
     def is_correct_type(self, w_key):
@@ -1229,7 +1229,7 @@
         return self.space.wrap(item)
 
     def iter(self, w_set):
-        return StringIteratorImplementation(self.space, self, w_set)
+        return BytesIteratorImplementation(self.space, self, w_set)
 
 
 class UnicodeSetStrategy(AbstractUnwrappedSetStrategy, SetStrategy):
@@ -1286,7 +1286,7 @@
         return type(w_key) is W_IntObject
 
     def may_contain_equal_elements(self, strategy):
-        if strategy is self.space.fromcache(StringSetStrategy):
+        if strategy is self.space.fromcache(BytesSetStrategy):
             return False
         elif strategy is self.space.fromcache(UnicodeSetStrategy):
             return False
@@ -1371,7 +1371,7 @@
             return False
         if strategy is self.space.fromcache(IntegerSetStrategy):
             return False
-        if strategy is self.space.fromcache(StringSetStrategy):
+        if strategy is self.space.fromcache(BytesSetStrategy):
             return False
         if strategy is self.space.fromcache(UnicodeSetStrategy):
             return False
@@ -1436,7 +1436,7 @@
         return None
 
 
-class StringIteratorImplementation(IteratorImplementation):
+class BytesIteratorImplementation(IteratorImplementation):
     def __init__(self, space, strategy, w_set):
         IteratorImplementation.__init__(self, space, strategy, w_set)
         d = strategy.unerase(w_set.sstorage)
@@ -1546,11 +1546,11 @@
         w_set.sstorage = w_iterable.get_storage_copy()
         return
 
-    stringlist = space.listview_str(w_iterable)
-    if stringlist is not None:
-        strategy = space.fromcache(StringSetStrategy)
+    byteslist = space.listview_bytes(w_iterable)
+    if byteslist is not None:
+        strategy = space.fromcache(BytesSetStrategy)
         w_set.strategy = strategy
-        w_set.sstorage = strategy.get_storage_from_unwrapped_list(stringlist)
+        w_set.sstorage = strategy.get_storage_from_unwrapped_list(byteslist)
         return
 
     unicodelist = space.listview_unicode(w_iterable)
@@ -1593,7 +1593,7 @@
         if type(w_item) is not W_BytesObject:
             break
     else:
-        w_set.strategy = space.fromcache(StringSetStrategy)
+        w_set.strategy = space.fromcache(BytesSetStrategy)
         w_set.sstorage = w_set.strategy.get_storage_from_list(iterable_w)
         return
 
diff --git a/pypy/objspace/std/stringmethods.py b/pypy/objspace/std/stringmethods.py
--- a/pypy/objspace/std/stringmethods.py
+++ b/pypy/objspace/std/stringmethods.py
@@ -311,7 +311,7 @@
         from pypy.objspace.std.unicodeobject import W_UnicodeObject
 
         if isinstance(self, W_BytesObject):
-            l = space.listview_str(w_list)
+            l = space.listview_bytes(w_list)
             if l is not None:
                 if len(l) == 1:
                     return space.wrap(l[0])
diff --git a/pypy/objspace/std/test/test_bytesobject.py b/pypy/objspace/std/test/test_bytesobject.py
--- a/pypy/objspace/std/test/test_bytesobject.py
+++ b/pypy/objspace/std/test/test_bytesobject.py
@@ -80,9 +80,9 @@
         w_slice = space.newslice(w(1), w_None, w(2))
         assert self.space.eq_w(space.getitem(w_str, w_slice), w('el'))
 
-    def test_listview_str(self):
+    def test_listview_bytes(self):
         w_str = self.space.wrap('abcd')
-        assert self.space.listview_str(w_str) == list("abcd")
+        assert self.space.listview_bytes(w_str) == list("abcd")
 
 class AppTestBytesObject:
 
diff --git a/pypy/objspace/std/test/test_dictmultiobject.py b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -2,7 +2,7 @@
 import py
 
 from pypy.objspace.std.dictmultiobject import (W_DictMultiObject,
-    StringDictStrategy, ObjectDictStrategy)
+    BytesDictStrategy, ObjectDictStrategy)
 
 
 class TestW_DictObject(object):
@@ -134,11 +134,11 @@
         assert space.eq_w(w_d.getitem_str("a"), space.w_None)
         assert space.eq_w(w_d.getitem_str("b"), space.w_None)
 
-    def test_listview_str_dict(self):
+    def test_listview_bytes_dict(self):
         w = self.space.wrap
         w_d = self.space.newdict()
         w_d.initialize_content([(w("a"), w(1)), (w("b"), w(2))])
-        assert self.space.listview_str(w_d) == ["a", "b"]
+        assert self.space.listview_bytes(w_d) == ["a", "b"]
 
     def test_listview_unicode_dict(self):
         w = self.space.wrap
@@ -160,7 +160,7 @@
         w_l = self.space.call_method(w_d, "keys")
         assert sorted(self.space.listview_int(w_l)) == [1,2]
         
-        # make sure that .keys() calls newlist_str for string dicts
+        # make sure that .keys() calls newlist_bytes for string dicts
         def not_allowed(*args):
             assert False, 'should not be called'
         monkeypatch.setattr(self.space, 'newlist', not_allowed)
@@ -168,7 +168,7 @@
         w_d = self.space.newdict()
         w_d.initialize_content([(w("a"), w(1)), (w("b"), w(6))])
         w_l = self.space.call_method(w_d, "keys")
-        assert sorted(self.space.listview_str(w_l)) == ["a", "b"]
+        assert sorted(self.space.listview_bytes(w_l)) == ["a", "b"]
 
         # XXX: it would be nice if the test passed without monkeypatch.undo(),
         # but we need space.newlist_unicode for it
@@ -944,7 +944,7 @@
         d = {}
         assert "EmptyDictStrategy" in self.get_strategy(d)
         d["a"] = 1
-        assert "StringDictStrategy" in self.get_strategy(d)
+        assert "BytesDictStrategy" in self.get_strategy(d)
 
         class O(object):
             pass
@@ -952,7 +952,7 @@
         d = o.__dict__ = {}
         assert "EmptyDictStrategy" in self.get_strategy(d)
         o.a = 1
-        assert "StringDictStrategy" in self.get_strategy(d)
+        assert "BytesDictStrategy" in self.get_strategy(d)
 
     def test_empty_to_unicode(self):
         d = {}
@@ -1033,7 +1033,7 @@
     eq_w = eq
     def newlist(self, l):
         return l
-    def newlist_str(self, l):
+    def newlist_bytes(self, l):
         return l
     DictObjectCls = W_DictMultiObject
     def type(self, w_obj):
@@ -1275,9 +1275,9 @@
         assert "s" not in d.w_keys()
         assert F() not in d.w_keys()
 
-class TestStrDictImplementation(BaseTestRDictImplementation):
-    StrategyClass = StringDictStrategy
-    #ImplementionClass = StrDictImplementation
+class TestBytesDictImplementation(BaseTestRDictImplementation):
+    StrategyClass = BytesDictStrategy
+    #ImplementionClass = BytesDictImplementation
 
     def test_str_shortcut(self):
         self.fill_impl()
@@ -1301,12 +1301,12 @@
     def check_not_devolved(self):
         pass
 
-class TestDevolvedStrDictImplementation(BaseTestDevolvedDictImplementation):
-    StrategyClass = StringDictStrategy
+class TestDevolvedBytesDictImplementation(BaseTestDevolvedDictImplementation):
+    StrategyClass = BytesDictStrategy
 
 
 def test_module_uses_strdict():
     fakespace = FakeSpace()
     d = fakespace.newdict(module=True)
-    assert type(d.strategy) is StringDictStrategy
+    assert type(d.strategy) is BytesDictStrategy
 
diff --git a/pypy/objspace/std/test/test_kwargsdict.py b/pypy/objspace/std/test/test_kwargsdict.py
--- a/pypy/objspace/std/test/test_kwargsdict.py
+++ b/pypy/objspace/std/test/test_kwargsdict.py
@@ -73,7 +73,7 @@
     for i in range(100):
         assert d.setitem_str("d%s" % i, 4) is None
     assert d.strategy is not strategy
-    assert "StringDictStrategy" == d.strategy.__class__.__name__
+    assert "BytesDictStrategy" == d.strategy.__class__.__name__
 
 def test_keys_doesnt_wrap():
     space = FakeSpace()
diff --git a/pypy/objspace/std/test/test_liststrategies.py b/pypy/objspace/std/test/test_liststrategies.py
--- a/pypy/objspace/std/test/test_liststrategies.py
+++ b/pypy/objspace/std/test/test_liststrategies.py
@@ -1,5 +1,5 @@
 import sys
-from pypy.objspace.std.listobject import W_ListObject, EmptyListStrategy, ObjectListStrategy, IntegerListStrategy, FloatListStrategy, StringListStrategy, RangeListStrategy, make_range_list, UnicodeListStrategy
+from pypy.objspace.std.listobject import W_ListObject, EmptyListStrategy, ObjectListStrategy, IntegerListStrategy, FloatListStrategy, BytesListStrategy, RangeListStrategy, make_range_list, UnicodeListStrategy
 from pypy.objspace.std import listobject
 from pypy.objspace.std.test.test_listobject import TestW_ListObject
 
@@ -13,7 +13,7 @@
         assert isinstance(W_ListObject(space, [w(1),w(2),w(3)]).strategy,
                           IntegerListStrategy)
         assert isinstance(W_ListObject(space, [w('a'), w('b')]).strategy,
-                          StringListStrategy)
+                          BytesListStrategy)
         assert isinstance(W_ListObject(space, [w(u'a'), w(u'b')]).strategy,
                           UnicodeListStrategy)
         assert isinstance(W_ListObject(space, [w(u'a'), w('b')]).strategy,
@@ -35,7 +35,7 @@
         l = W_ListObject(space, [])
         assert isinstance(l.strategy, EmptyListStrategy)
         l.append(w('a'))
-        assert isinstance(l.strategy, StringListStrategy)
+        assert isinstance(l.strategy, BytesListStrategy)
 
         l = W_ListObject(space, [])
         assert isinstance(l.strategy, EmptyListStrategy)
@@ -59,9 +59,9 @@
     def test_string_to_any(self):
         l = W_ListObject(self.space,
                          [self.space.wrap('a'),self.space.wrap('b'),self.space.wrap('c')])
-        assert isinstance(l.strategy, StringListStrategy)
+        assert isinstance(l.strategy, BytesListStrategy)
         l.append(self.space.wrap('d'))
-        assert isinstance(l.strategy, StringListStrategy)
+        assert isinstance(l.strategy, BytesListStrategy)
         l.append(self.space.wrap(3))
         assert isinstance(l.strategy, ObjectListStrategy)
 
@@ -92,7 +92,7 @@
         l.setitem(0, w('d'))
         assert space.eq_w(l.getitem(0), w('d'))
 
-        assert isinstance(l.strategy, StringListStrategy)
+        assert isinstance(l.strategy, BytesListStrategy)
 
         # IntStrategy to ObjectStrategy
         l = W_ListObject(space, [w(1),w(2),w(3)])
@@ -100,9 +100,9 @@
         l.setitem(0, w('d'))
         assert isinstance(l.strategy, ObjectListStrategy)
 
-        # StringStrategy to ObjectStrategy
+        # BytesStrategy to ObjectStrategy
         l = W_ListObject(space, [w('a'),w('b'),w('c')])
-        assert isinstance(l.strategy, StringListStrategy)
+        assert isinstance(l.strategy, BytesListStrategy)
         l.setitem(0, w(2))
         assert isinstance(l.strategy, ObjectListStrategy)
 
@@ -127,9 +127,9 @@
         l.insert(3, w(4))
         assert isinstance(l.strategy, IntegerListStrategy)
 
-        # StringStrategy
+        # BytesStrategy
         l = W_ListObject(space, [w('a'),w('b'),w('c')])
-        assert isinstance(l.strategy, StringListStrategy)
+        assert isinstance(l.strategy, BytesListStrategy)
         l.insert(3, w(2))
         assert isinstance(l.strategy, ObjectListStrategy)
 
@@ -155,7 +155,7 @@
         l = W_ListObject(space, [])
         assert isinstance(l.strategy, EmptyListStrategy)
         l.insert(0, w('a'))
-        assert isinstance(l.strategy, StringListStrategy)
+        assert isinstance(l.strategy, BytesListStrategy)
 
         l = W_ListObject(space, [])
         assert isinstance(l.strategy, EmptyListStrategy)
@@ -207,9 +207,9 @@
         l.setslice(0, 1, 2, W_ListObject(space, [w('a'), w('b'), w('c')]))
         assert isinstance(l.strategy, ObjectListStrategy)
 
-        # StringStrategy to ObjectStrategy
+        # BytesStrategy to ObjectStrategy
         l = W_ListObject(space, [w('a'), w('b'), w('c')])
-        assert isinstance(l.strategy, StringListStrategy)
+        assert isinstance(l.strategy, BytesListStrategy)
         l.setslice(0, 1, 2, W_ListObject(space, [w(1), w(2), w(3)]))
         assert isinstance(l.strategy, ObjectListStrategy)
 
@@ -261,7 +261,7 @@
         l = W_ListObject(space, wrapitems(["a","b","c","d","e"]))
         other = W_ListObject(space, wrapitems(["a", "b", "c"]))
         keep_other_strategy(l, 0, 2, other.length(), other)
-        assert l.strategy is space.fromcache(StringListStrategy)
+        assert l.strategy is space.fromcache(BytesListStrategy)
 
         l = W_ListObject(space, wrapitems([u"a",u"b",u"c",u"d",u"e"]))
         other = W_ListObject(space, wrapitems([u"a", u"b", u"c"]))
@@ -330,7 +330,7 @@
         empty = W_ListObject(space, [])
         assert isinstance(empty.strategy, EmptyListStrategy)
         empty.extend(W_ListObject(space, [w("a"), w("b"), w("c")]))
-        assert isinstance(empty.strategy, StringListStrategy)
+        assert isinstance(empty.strategy, BytesListStrategy)
 
         empty = W_ListObject(space, [])
         assert isinstance(empty.strategy, EmptyListStrategy)
@@ -514,17 +514,17 @@
 
     def test_unicode(self):
         l1 = W_ListObject(self.space, [self.space.wrap("eins"), self.space.wrap("zwei")])
-        assert isinstance(l1.strategy, StringListStrategy)
+        assert isinstance(l1.strategy, BytesListStrategy)
         l2 = W_ListObject(self.space, [self.space.wrap(u"eins"), self.space.wrap(u"zwei")])
         assert isinstance(l2.strategy, UnicodeListStrategy)
         l3 = W_ListObject(self.space, [self.space.wrap("eins"), self.space.wrap(u"zwei")])
         assert isinstance(l3.strategy, ObjectListStrategy)
 
-    def test_listview_str(self):
+    def test_listview_bytes(self):
         space = self.space
-        assert space.listview_str(space.wrap(1)) == None
+        assert space.listview_bytes(space.wrap(1)) == None
         w_l = self.space.newlist([self.space.wrap('a'), self.space.wrap('b')])
-        assert space.listview_str(w_l) == ["a", "b"]
+        assert space.listview_bytes(w_l) == ["a", "b"]
 
     def test_listview_unicode(self):
         space = self.space
@@ -532,7 +532,7 @@
         w_l = self.space.newlist([self.space.wrap(u'a'), self.space.wrap(u'b')])
         assert space.listview_unicode(w_l) == [u"a", u"b"]
 
-    def test_string_join_uses_listview_str(self):
+    def test_string_join_uses_listview_bytes(self):
         space = self.space
         w_l = self.space.newlist([self.space.wrap('a'), self.space.wrap('b')])
         w_l.getitems = None
@@ -556,14 +556,14 @@
         w_l.getitems = None
         assert space.is_w(space.call_method(space.wrap(u" -- "), "join", w_l), w_text)
 
-    def test_newlist_str(self):
+    def test_newlist_bytes(self):
         space = self.space
         l = ['a', 'b']
-        w_l = self.space.newlist_str(l)
-        assert isinstance(w_l.strategy, StringListStrategy)
-        assert space.listview_str(w_l) is l
+        w_l = self.space.newlist_bytes(l)
+        assert isinstance(w_l.strategy, BytesListStrategy)
+        assert space.listview_bytes(w_l) is l
 
-    def test_string_uses_newlist_str(self):
+    def test_string_uses_newlist_bytes(self):
         space = self.space
         w_s = space.wrap("a b c")
         space.newlist = None
@@ -574,10 +574,10 @@
             w_l4 = space.call_method(w_s, "rsplit", space.wrap(" "))
         finally:
             del space.newlist
-        assert space.listview_str(w_l) == ["a", "b", "c"]
-        assert space.listview_str(w_l2) == ["a", "b", "c"]
-        assert space.listview_str(w_l3) == ["a", "b", "c"]
-        assert space.listview_str(w_l4) == ["a", "b", "c"]
+        assert space.listview_bytes(w_l) == ["a", "b", "c"]
+        assert space.listview_bytes(w_l2) == ["a", "b", "c"]
+        assert space.listview_bytes(w_l3) == ["a", "b", "c"]
+        assert space.listview_bytes(w_l4) == ["a", "b", "c"]
 
     def test_unicode_uses_newlist_unicode(self):
         space = self.space
@@ -630,10 +630,10 @@
         assert space.eq_w(w_l, w_l2)
 
 
-    def test_listview_str_list(self):
+    def test_listview_bytes_list(self):
         space = self.space
         w_l = W_ListObject(space, [space.wrap("a"), space.wrap("b")])
-        assert self.space.listview_str(w_l) == ["a", "b"]
+        assert self.space.listview_bytes(w_l) == ["a", "b"]
 
     def test_listview_unicode_list(self):
         space = self.space
diff --git a/pypy/objspace/std/test/test_setobject.py b/pypy/objspace/std/test/test_setobject.py
--- a/pypy/objspace/std/test/test_setobject.py
+++ b/pypy/objspace/std/test/test_setobject.py
@@ -82,7 +82,7 @@
 
     def test_create_set_from_list(self):
         from pypy.interpreter.baseobjspace import W_Root
-        from pypy.objspace.std.setobject import ObjectSetStrategy, StringSetStrategy, UnicodeSetStrategy
+        from pypy.objspace.std.setobject import BytesSetStrategy, ObjectSetStrategy, UnicodeSetStrategy
         from pypy.objspace.std.floatobject import W_FloatObject
 
         w = self.space.wrap
@@ -100,7 +100,7 @@
         w_list = W_ListObject(self.space, [w("1"), w("2"), w("3")])
         w_set = W_SetObject(self.space)
         _initialize_set(self.space, w_set, w_list)
-        assert w_set.strategy is self.space.fromcache(StringSetStrategy)
+        assert w_set.strategy is self.space.fromcache(BytesSetStrategy)
         assert w_set.strategy.unerase(w_set.sstorage) == {"1":None, "2":None, "3":None}
 
         w_list = self.space.iter(W_ListObject(self.space, [w(u"1"), w(u"2"), w(u"3")]))
@@ -126,18 +126,18 @@
         # changed cached object, need to change it back for other tests to pass
         intstr.get_storage_from_list = tmp_func
 
-    def test_listview_str_int_on_set(self):
+    def test_listview_bytes_int_on_set(self):
         w = self.space.wrap
 
         w_a = W_SetObject(self.space)
         _initialize_set(self.space, w_a, w("abcdefg"))
-        assert sorted(self.space.listview_str(w_a)) == list("abcdefg")
+        assert sorted(self.space.listview_bytes(w_a)) == list("abcdefg")
         assert self.space.listview_int(w_a) is None
 
         w_b = W_SetObject(self.space)
         _initialize_set(self.space, w_b, self.space.newlist([w(1),w(2),w(3),w(4),w(5)]))
         assert sorted(self.space.listview_int(w_b)) == [1,2,3,4,5]
-        assert self.space.listview_str(w_b) is None
+        assert self.space.listview_bytes(w_b) is None
 
 class AppTestAppSetTest:
 
diff --git a/pypy/objspace/std/test/test_setstrategies.py b/pypy/objspace/std/test/test_setstrategies.py
--- a/pypy/objspace/std/test/test_setstrategies.py
+++ b/pypy/objspace/std/test/test_setstrategies.py
@@ -1,10 +1,8 @@
 from pypy.objspace.std.setobject import W_SetObject
-from pypy.objspace.std.setobject import (IntegerSetStrategy, ObjectSetStrategy,
-                                         EmptySetStrategy, StringSetStrategy,
-                                         UnicodeSetStrategy,
-                                         IntegerIteratorImplementation,
-                                         StringIteratorImplementation,
-                                         UnicodeIteratorImplementation)
+from pypy.objspace.std.setobject import (
+    BytesIteratorImplementation, BytesSetStrategy, EmptySetStrategy,
+    IntegerIteratorImplementation, IntegerSetStrategy, ObjectSetStrategy,
+    UnicodeIteratorImplementation, UnicodeSetStrategy)
 from pypy.objspace.std.listobject import W_ListObject
 
 class TestW_SetStrategies:
@@ -26,7 +24,7 @@
         assert s.strategy is self.space.fromcache(EmptySetStrategy)
 
         s = W_SetObject(self.space, self.wrapped(["a", "b"]))
-        assert s.strategy is self.space.fromcache(StringSetStrategy)
+        assert s.strategy is self.space.fromcache(BytesSetStrategy)
 
         s = W_SetObject(self.space, self.wrapped([u"a", u"b"]))
         assert s.strategy is self.space.fromcache(UnicodeSetStrategy)
@@ -126,7 +124,7 @@
         #
         s = W_SetObject(space, self.wrapped(["a", "b"]))
         it = s.iter()
-        assert isinstance(it, StringIteratorImplementation)
+        assert isinstance(it, BytesIteratorImplementation)
         assert space.unwrap(it.next()) == "a"
         assert space.unwrap(it.next()) == "b"
         #
@@ -142,7 +140,7 @@
         assert sorted(space.listview_int(s)) == [1, 2]
         #
         s = W_SetObject(space, self.wrapped(["a", "b"]))
-        assert sorted(space.listview_str(s)) == ["a", "b"]
+        assert sorted(space.listview_bytes(s)) == ["a", "b"]
         #
         s = W_SetObject(space, self.wrapped([u"a", u"b"]))
         assert sorted(space.listview_unicode(s)) == [u"a", u"b"]
diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -531,7 +531,7 @@
         """x.__getitem__(y) <==> x[y]"""
 
     def __getnewargs__():
-        """"""
+        ""
 
     def __getslice__():
         """x.__getslice__(i, j) <==> x[i:j]
diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py
--- a/rpython/annotator/annrpython.py
+++ b/rpython/annotator/annrpython.py
@@ -9,7 +9,7 @@
 from rpython.flowspace.model import (Variable, Constant, FunctionGraph,
                                       c_last_exception, checkgraph)
 from rpython.translator import simplify, transform
-from rpython.annotator import model as annmodel, signature, unaryop, binaryop
+from rpython.annotator import model as annmodel, signature
 from rpython.annotator.bookkeeper import Bookkeeper
 
 import py
@@ -455,12 +455,12 @@
         # occour for this specific, typed operation.
         if block.exitswitch == c_last_exception:
             op = block.operations[-1]
-            if op.opname in binaryop.BINARY_OPERATIONS:
+            if op.dispatch == 2:
                 arg1 = self.binding(op.args[0])
                 arg2 = self.binding(op.args[1])
                 binop = getattr(pair(arg1, arg2), op.opname, None)
                 can_only_throw = annmodel.read_can_only_throw(binop, arg1, arg2)
-            elif op.opname in unaryop.UNARY_OPERATIONS:
+            elif op.dispatch == 1:
                 arg1 = self.binding(op.args[0])
                 opname = op.opname
                 if opname == 'contains': opname = 'op_contains'
@@ -611,44 +611,6 @@
     def noreturnvalue(self, op):
         return annmodel.s_ImpossibleValue  # no return value (hook method)
 
-    # XXX "contains" clash with SomeObject method
-    def consider_op_contains(self, seq, elem):
-        self.bookkeeper.count("contains", seq)
-        return seq.op_contains(elem)
-
-    def consider_op_newtuple(self, *args):
-        return annmodel.SomeTuple(items = args)
-
-    def consider_op_newlist(self, *args):
-        return self.bookkeeper.newlist(*args)
-
-    def consider_op_newdict(self):
-        return self.bookkeeper.newdict()
-
-
-    def _registeroperations(cls, unary_ops, binary_ops):
-        # All unary operations
-        d = {}
-        for opname in unary_ops:
-            fnname = 'consider_op_' + opname
-            exec py.code.Source("""
-def consider_op_%s(self, arg, *args):
-    return arg.%s(*args)
-""" % (opname, opname)).compile() in globals(), d
-            setattr(cls, fnname, d[fnname])
-        # All binary operations
-        for opname in binary_ops:
-            fnname = 'consider_op_' + opname
-            exec py.code.Source("""
-def consider_op_%s(self, arg1, arg2, *args):
-    return pair(arg1,arg2).%s(*args)
-""" % (opname, opname)).compile() in globals(), d
-            setattr(cls, fnname, d[fnname])
-    _registeroperations = classmethod(_registeroperations)
-
-# register simple operations handling
-RPythonAnnotator._registeroperations(unaryop.UNARY_OPERATIONS, binaryop.BINARY_OPERATIONS)
-
 
 class BlockedInference(Exception):
     """This exception signals the type inference engine that the situation
diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py
--- a/rpython/annotator/binaryop.py
+++ b/rpython/annotator/binaryop.py
@@ -12,10 +12,11 @@
     SomeBuiltin, SomeIterator, SomePBC, SomeFloat, s_None, SomeByteArray,
     SomeWeakRef, SomeAddress, SomeTypedAddressAccess, SomeSingleFloat,
     SomeLongFloat, SomeType, SomeConstantType, unionof, UnionError,
-    missing_operation, read_can_only_throw, add_knowntypedata,
+    read_can_only_throw, add_knowntypedata,
     merge_knowntypedata,)
 from rpython.annotator.bookkeeper import getbookkeeper
 from rpython.flowspace.model import Variable, Constant
+from rpython.flowspace.operation import op
 from rpython.rlib import rarithmetic
 from rpython.annotator.model import AnnotatorError
 
@@ -23,28 +24,9 @@
 def immutablevalue(x):
     return getbookkeeper().immutablevalue(x)
 
-# XXX unify this with ObjSpace.MethodTable
-BINARY_OPERATIONS = set(['add', 'sub', 'mul', 'div', 'mod',
-                         'truediv', 'floordiv', 'divmod',
-                         'and_', 'or_', 'xor',
-                         'lshift', 'rshift',
-                         'getitem', 'setitem', 'delitem',
-                         'getitem_idx', 'getitem_key', 'getitem_idx_key',
-                         'inplace_add', 'inplace_sub', 'inplace_mul',
-                         'inplace_truediv', 'inplace_floordiv', 'inplace_div',
-                         'inplace_mod',
-                         'inplace_lshift', 'inplace_rshift',
-                         'inplace_and', 'inplace_or', 'inplace_xor',
-                         'lt', 'le', 'eq', 'ne', 'gt', 'ge', 'is_', 'cmp',
-                         'coerce',
-                         ]
-                        +[opname+'_ovf' for opname in
-                          """add sub mul floordiv div mod lshift
-                           """.split()
-                          ])
+BINARY_OPERATIONS = set([oper.opname for oper in op.__dict__.values()
+                        if oper.dispatch == 2])
 
-for opname in BINARY_OPERATIONS:
-    missing_operation(pairtype(SomeObject, SomeObject), opname)
 
 class __extend__(pairtype(SomeObject, SomeObject)):
 
@@ -78,46 +60,39 @@
         if obj1.is_immutable_constant() and obj2.is_immutable_constant():
             return immutablevalue(obj1.const < obj2.const)
         else:
-            getbookkeeper().count("non_int_comp", obj1, obj2)
             return s_Bool
 
     def le((obj1, obj2)):
         if obj1.is_immutable_constant() and obj2.is_immutable_constant():
             return immutablevalue(obj1.const <= obj2.const)
         else:
-            getbookkeeper().count("non_int_comp", obj1, obj2)
             return s_Bool
 
     def eq((obj1, obj2)):
         if obj1.is_immutable_constant() and obj2.is_immutable_constant():
             return immutablevalue(obj1.const == obj2.const)
         else:
-            getbookkeeper().count("non_int_eq", obj1, obj2)
             return s_Bool
 
     def ne((obj1, obj2)):
         if obj1.is_immutable_constant() and obj2.is_immutable_constant():
             return immutablevalue(obj1.const != obj2.const)
         else:
-            getbookkeeper().count("non_int_eq", obj1, obj2)
             return s_Bool
 
     def gt((obj1, obj2)):
         if obj1.is_immutable_constant() and obj2.is_immutable_constant():
             return immutablevalue(obj1.const > obj2.const)
         else:
-            getbookkeeper().count("non_int_comp", obj1, obj2)
             return s_Bool
 
     def ge((obj1, obj2)):
         if obj1.is_immutable_constant() and obj2.is_immutable_constant():
             return immutablevalue(obj1.const >= obj2.const)
         else:
-            getbookkeeper().count("non_int_comp", obj1, obj2)
             return s_Bool
 
     def cmp((obj1, obj2)):
-        getbookkeeper().count("cmp", obj1, obj2)
         if obj1.is_immutable_constant() and obj2.is_immutable_constant():
             return immutablevalue(cmp(obj1.const, obj2.const))
         else:
@@ -163,13 +138,19 @@
         return r
 
     def divmod((obj1, obj2)):
-        getbookkeeper().count("divmod", obj1, obj2)
         return SomeTuple([pair(obj1, obj2).div(), pair(obj1, obj2).mod()])
 
     def coerce((obj1, obj2)):
-        getbookkeeper().count("coerce", obj1, obj2)
         return pair(obj1, obj2).union()   # reasonable enough
 
+    def getitem((obj1, obj2)):
+        return s_ImpossibleValue
+    add = sub = mul = truediv = floordiv = div = mod = getitem
+    lshift = rshift = and_ = or_ = xor = delitem = getitem
+
+    def setitem((obj1, obj2), _):
+        return s_ImpossibleValue
+
     # approximation of an annotation intersection, the result should be the annotation obj or
     # the intersection of obj and improvement
     def improve((obj, improvement)):
@@ -466,7 +447,6 @@
                                                   SomeUnicodeString))):
                 raise AnnotatorError(
                     "string formatting mixing strings and unicode not supported")
-        getbookkeeper().count('strformat', s_string, s_tuple)
         no_nul = s_string.no_nul
         for s_item in s_tuple.items:
             if isinstance(s_item, SomeFloat):
@@ -484,7 +464,6 @@
                  pairtype(SomeUnicodeString, SomeObject)):
 
     def mod((s_string, args)):
-        getbookkeeper().count('strformat', s_string, args)
         return s_string.__class__()
 
 class __extend__(pairtype(SomeFloat, SomeFloat)):
@@ -586,19 +565,16 @@
         return [KeyError]
 
     def getitem((dic1, obj2)):
-        getbookkeeper().count("dict_getitem", dic1)
         dic1.dictdef.generalize_key(obj2)
         return dic1.dictdef.read_value()
     getitem.can_only_throw = _can_only_throw
 
     def setitem((dic1, obj2), s_value):
-        getbookkeeper().count("dict_setitem", dic1)
         dic1.dictdef.generalize_key(obj2)
         dic1.dictdef.generalize_value(s_value)
     setitem.can_only_throw = _can_only_throw
 
     def delitem((dic1, obj2)):
-        getbookkeeper().count("dict_delitem", dic1)
         dic1.dictdef.generalize_key(obj2)
     delitem.can_only_throw = _can_only_throw
 
@@ -612,7 +588,6 @@
             except IndexError:
                 return s_ImpossibleValue
         else:
-            getbookkeeper().count("tuple_random_getitem", tup1)
             return unionof(*tup1.items)
     getitem.can_only_throw = [IndexError]
 
@@ -623,74 +598,63 @@
         return lst1.listdef.offspring()
 
     def getitem((lst1, int2)):
-        getbookkeeper().count("list_getitem", int2)
         return lst1.listdef.read_item()
     getitem.can_only_throw = []
 
     getitem_key = getitem
 
     def getitem_idx((lst1, int2)):
-        getbookkeeper().count("list_getitem", int2)
         return lst1.listdef.read_item()
     getitem_idx.can_only_throw = [IndexError]
 
     getitem_idx_key = getitem_idx
 
     def setitem((lst1, int2), s_value):
-        getbookkeeper().count("list_setitem", int2)
         lst1.listdef.mutate()
         lst1.listdef.generalize(s_value)
     setitem.can_only_throw = [IndexError]
 
     def delitem((lst1, int2)):
-        getbookkeeper().count("list_delitem", int2)
         lst1.listdef.resize()
     delitem.can_only_throw = [IndexError]
 
 class __extend__(pairtype(SomeString, SomeInteger)):
 
     def getitem((str1, int2)):
-        getbookkeeper().count("str_getitem", int2)
         return SomeChar(no_nul=str1.no_nul)
     getitem.can_only_throw = []
 
     getitem_key = getitem
 
     def getitem_idx((str1, int2)):
-        getbookkeeper().count("str_getitem", int2)
         return SomeChar(no_nul=str1.no_nul)
     getitem_idx.can_only_throw = [IndexError]
 
     getitem_idx_key = getitem_idx
 
     def mul((str1, int2)): # xxx do we want to support this
-        getbookkeeper().count("str_mul", str1, int2)
         return SomeString(no_nul=str1.no_nul)
 
 class __extend__(pairtype(SomeUnicodeString, SomeInteger)):
     def getitem((str1, int2)):
-        getbookkeeper().count("str_getitem", int2)
         return SomeUnicodeCodePoint()
     getitem.can_only_throw = []
 
     getitem_key = getitem
 
     def getitem_idx((str1, int2)):
-        getbookkeeper().count("str_getitem", int2)
         return SomeUnicodeCodePoint()
     getitem_idx.can_only_throw = [IndexError]
 
     getitem_idx_key = getitem_idx
 
     def mul((str1, int2)): # xxx do we want to support this
-        getbookkeeper().count("str_mul", str1, int2)
         return SomeUnicodeString()
 
 class __extend__(pairtype(SomeInteger, SomeString),
                  pairtype(SomeInteger, SomeUnicodeString)):
 
     def mul((int1, str2)): # xxx do we want to support this
-        getbookkeeper().count("str_mul", str2, int1)
         return str2.basestringclass()
 
 class __extend__(pairtype(SomeUnicodeCodePoint, SomeUnicodeString),
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -25,112 +25,6 @@
 from rpython.rtyper import extregistry
 
 
-class Stats(object):
-
-    def __init__(self, bookkeeper):
-        self.bookkeeper = bookkeeper
-        self.classify = {}
-
-    def count(self, category, *args):
-        for_category = self.classify.setdefault(category, {})
-        classifier = getattr(self, 'consider_%s' % category, self.consider_generic)
-        outcome = classifier(*args)
-        for_category[self.bookkeeper.position_key] = outcome
-
-    def indexrepr(self, idx):
-        if idx.is_constant():
-            if idx.const is None:
-                return ''
-            if isinstance(idx, SomeInteger):
-                if idx.const >=0:
-                    return 'pos-constant'
-                else:
-                    return 'Neg-constant'
-            return idx.const
-        else:
-            if isinstance(idx, SomeInteger):
-                if idx.nonneg:
-                    return "non-neg"
-                else:
-                    return "MAYBE-NEG"
-            else:
-                return self.typerepr(idx)
-
-    def steprepr(self, stp):
-        if stp.is_constant():
-            if stp.const in (1, None):
-                return 'step=1'
-            else:
-                return 'step=%s?' % stp.const
-        else:
-            return 'non-const-step %s' % self.typerepr(stp)
-
-    def consider_generic(self, *args):
-        return tuple([self.typerepr(x) for x in args])
-
-    def consider_list_list_eq(self, obj1, obj2):
-        return obj1, obj2
-
-    def consider_contains(self, seq):
-        return seq
-
-    def consider_non_int_eq(self, obj1, obj2):
-        if obj1.knowntype == obj2.knowntype == list:
-            self.count("list_list_eq", obj1, obj2)
-        return self.typerepr(obj1), self.typerepr(obj2)
-
-    def consider_non_int_comp(self, obj1, obj2):
-        return self.typerepr(obj1), self.typerepr(obj2)
-
-    def typerepr(self, obj):
-        if isinstance(obj, SomeInstance):
-            return obj.classdef.name
-        else:
-            return obj.knowntype.__name__
-
-    def consider_tuple_random_getitem(self, tup):
-        return tuple([self.typerepr(x) for x in tup.items])
-
-    def consider_list_index(self):
-        return '!'
-
-    def consider_list_getitem(self, idx):
-        return self.indexrepr(idx)
-
-    def consider_list_setitem(self, idx):
-        return self.indexrepr(idx)
-
-    def consider_list_delitem(self, idx):
-        return self.indexrepr(idx)
-
-    def consider_str_join(self, s):
-        if s.is_constant():
-            return repr(s.const)
-        else:
-            return "NON-CONSTANT"
-
-    def consider_str_getitem(self, idx):
-        return self.indexrepr(idx)
-
-    def consider_strformat(self, str, args):
-        if str.is_constant():
-            s = repr(str.const)
-        else:
-            s = "?!!!!!!"
-        if isinstance(args, SomeTuple):
-            return (s, tuple([self.typerepr(x) for x in args.items]))
-        else:
-            return (s, self.typerepr(args))
-
-    def consider_dict_getitem(self, dic):
-        return dic
-
-    def consider_dict_setitem(self, dic):
-        return dic
-
-    def consider_dict_delitem(self, dic):
-        return dic
-
 class Bookkeeper(object):
     """The log of choices that have been made while analysing the operations.
     It ensures that the same 'choice objects' will be returned if we ask
@@ -165,13 +59,8 @@
 
         self.needs_generic_instantiate = {}
 
-        self.stats = Stats(self)
-
         delayed_imports()
 
-    def count(self, category, *args):
-        self.stats.count(category, *args)
-
     def enter(self, position_key):
         """Start of an operation.
         The operation is uniquely identified by the given key."""
diff --git a/rpython/annotator/builtin.py b/rpython/annotator/builtin.py
--- a/rpython/annotator/builtin.py
+++ b/rpython/annotator/builtin.py
@@ -347,9 +347,6 @@
 def test(*args):
     return s_Bool
 
-def import_func(*args):
-    return SomeObject()
-
 # collect all functions
 import __builtin__
 BUILTIN_ANALYZERS = {}
@@ -397,9 +394,6 @@
 else:
     BUILTIN_ANALYZERS[object.__init__] = object_init
 
-# import
-BUILTIN_ANALYZERS[__import__] = import_func
-
 # annotation of low-level types
 from rpython.annotator.model import SomePtr
 from rpython.rtyper.lltypesystem import lltype
diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -799,21 +799,6 @@
     assert 0, "couldn't get to commonbase of %r and %r" % (cls1, cls2)
 
 
-def missing_operation(cls, name):
-    def default_op(*args):
-        if args and isinstance(args[0], tuple):
-            flattened = tuple(args[0]) + args[1:]
-        else:
-            flattened = args
-        for arg in flattened:
-            if arg.__class__ is SomeObject and arg.knowntype is not type:
-                return SomeObject()
-        bookkeeper = rpython.annotator.bookkeeper.getbookkeeper()
-        bookkeeper.warning("no precise annotation supplied for %s%r" % (name, args))
-        return s_ImpossibleValue
-    setattr(cls, name, default_op)
-
-
 class HarmlesslyBlocked(Exception):
     """Raised by the unaryop/binaryop to signal a harmless kind of
     BlockedInference: the current block is blocked, but not in a way
diff --git a/rpython/annotator/test/test_annrpython.py b/rpython/annotator/test/test_annrpython.py
--- a/rpython/annotator/test/test_annrpython.py
+++ b/rpython/annotator/test/test_annrpython.py
@@ -14,7 +14,8 @@
 from rpython.rlib.rarithmetic import r_uint, base_int, r_longlong, r_ulonglong
 from rpython.rlib.rarithmetic import r_singlefloat
 from rpython.rlib import objectmodel
-from rpython.flowspace.objspace import build_flow, FlowingError
+from rpython.flowspace.objspace import build_flow
+from rpython.flowspace.flowcontext import FlowingError
 from rpython.flowspace.operation import op
 
 from rpython.translator.test import snippet
diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -5,11 +5,12 @@
 from __future__ import absolute_import
 
 from types import MethodType
+from rpython.flowspace.operation import op
 from rpython.annotator.model import (SomeObject, SomeInteger, SomeBool,
     SomeString, SomeChar, SomeList, SomeDict, SomeTuple, SomeImpossibleValue,
     SomeUnicodeCodePoint, SomeInstance, SomeBuiltin, SomeFloat, SomeIterator,
     SomePBC, SomeTypedAddressAccess, SomeAddress, SomeType, s_ImpossibleValue,
-    s_Bool, s_None, unionof, missing_operation, add_knowntypedata,
+    s_Bool, s_None, unionof, add_knowntypedata,
     HarmlesslyBlocked, SomeWeakRef, SomeUnicodeString, SomeByteArray)
 from rpython.annotator.bookkeeper import getbookkeeper
 from rpython.annotator import builtin
@@ -20,17 +21,8 @@
 def immutablevalue(x):
     return getbookkeeper().immutablevalue(x)
 
-UNARY_OPERATIONS = set(['len', 'bool', 'getattr', 'setattr', 'delattr',
-                        'simple_call', 'call_args', 'str', 'repr',
-                        'iter', 'next', 'invert', 'type', 'issubtype',
-                        'pos', 'neg', 'abs', 'hex', 'oct',
-                        'ord', 'int', 'float', 'long',
-                        'hash', 'id',    # <== not supported any more
-                        'getslice', 'setslice', 'delslice',
-                        'neg_ovf', 'abs_ovf', 'hint', 'unicode', 'unichr'])
-
-for opname in UNARY_OPERATIONS:
-    missing_operation(SomeObject, opname)
+UNARY_OPERATIONS = set([oper.opname for oper in op.__dict__.values()
+                        if oper.dispatch == 1])
 
 
 class __extend__(SomeObject):
@@ -84,23 +76,18 @@
         raise AnnotatorError("cannot use hash() in RPython")
 
     def str(self):
-        getbookkeeper().count('str', self)
         return SomeString()
 
     def unicode(self):
-        getbookkeeper().count('unicode', self)
         return SomeUnicodeString()
 
     def repr(self):
-        getbookkeeper().count('repr', self)
         return SomeString()
 
     def hex(self):
-        getbookkeeper().count('hex', self)
         return SomeString()
 
     def oct(self):
-        getbookkeeper().count('oct', self)
         return SomeString()
 
     def id(self):
@@ -144,6 +131,9 @@
         raise AnnotatorError("Cannot find attribute %r on %r" % (attr, self))
     getattr.can_only_throw = []
 
+    def setattr(self, *args):
+        return s_ImpossibleValue
+
     def bind_callables_under(self, classdef, name):
         return self   # default unbound __get__ implementation
 
@@ -163,6 +153,20 @@
     def hint(self, *args_s):
         return self
 
+    def getslice(self, *args):
+        return s_ImpossibleValue
+
+    def setslice(self, *args):
+        return s_ImpossibleValue
+
+    def delslice(self, *args):
+        return s_ImpossibleValue
+
+    def pos(self):
+        return s_ImpossibleValue
+    neg = abs = ord = invert = long = iter = next = pos
+
+
 class __extend__(SomeFloat):
 
     def pos(self):
@@ -237,7 +241,6 @@
         return immutablevalue(len(self.items))
 
     def iter(self):
-        getbookkeeper().count("tuple_iter", self)
         return SomeIterator(self)
     iter.can_only_throw = []
 
@@ -281,7 +284,6 @@
     method_pop.can_only_throw = [IndexError]
 
     def method_index(self, s_value):
-        getbookkeeper().count("list_index")
         self.listdef.generalize(s_value)
         return SomeInteger(nonneg=True)
 
@@ -472,7 +474,6 @@
     def method_join(self, s_list):
         if s_None.contains(s_list):
             return SomeImpossibleValue()
-        getbookkeeper().count("str_join", self)
         s_item = s_list.listdef.read_item()
         if s_None.contains(s_item):
             if isinstance(self, SomeUnicodeString):
@@ -489,7 +490,6 @@
         return self.basecharclass()
 
     def method_split(self, patt, max=-1):
-        getbookkeeper().count("str_split", self, patt)
         if max == -1 and patt.is_constant() and patt.const == "\0":
             no_nul = True
         else:
@@ -498,7 +498,6 @@
         return getbookkeeper().newlist(s_item)
 
     def method_rsplit(self, patt, max=-1):
-        getbookkeeper().count("str_rsplit", self, patt)
         s_item = self.basestringclass(no_nul=self.no_nul)
         return getbookkeeper().newlist(s_item)
 
@@ -709,8 +708,6 @@
         if self.s_self is not None:
             return self.analyser(self.s_self, *args)
         else:
-            if self.methodname:
-                getbookkeeper().count(self.methodname.replace('.', '_'), *args)
             return self.analyser(*args)
     simple_call.can_only_throw = _can_only_throw
 
diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -34,8 +34,8 @@
     opnames = host_bytecode_spec.method_names
 
     def __init__(self, argcount, nlocals, stacksize, flags,
-                     code, consts, names, varnames, filename,
-                     name, firstlineno, lnotab, freevars):
+                 code, consts, names, varnames, filename,
+                 name, firstlineno, lnotab, freevars):
         """Initialize a new code object"""
         assert nlocals >= 0
         self.co_argcount = argcount
@@ -58,18 +58,18 @@
         """Initialize the code object from a real (CPython) one.
         """
         return cls(code.co_argcount,
-                      code.co_nlocals,
-                      code.co_stacksize,
-                      code.co_flags,
-                      code.co_code,
-                      list(code.co_consts),
-                      list(code.co_names),
-                      list(code.co_varnames),
-                      code.co_filename,
-                      code.co_name,
-                      code.co_firstlineno,
-                      code.co_lnotab,
-                      list(code.co_freevars))
+                   code.co_nlocals,
+                   code.co_stacksize,
+                   code.co_flags,
+                   code.co_code,
+                   list(code.co_consts),
+                   list(code.co_names),
+                   list(code.co_varnames),
+                   code.co_filename,
+                   code.co_name,
+                   code.co_firstlineno,
+                   code.co_lnotab,
+                   list(code.co_freevars))
 
     @property
     def formalargcount(self):
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -1,12 +1,14 @@
-"""Implements the core parts of flow graph creation, in tandem
-with rpython.flowspace.objspace.
+"""Implements the core parts of flow graph creation.
 """
 
 import sys
 import collections
+import types
+import __builtin__
 
 from rpython.tool.error import source_lines
 from rpython.tool.stdlib_opcode import host_bytecode_spec
+from rpython.rlib import rstackovf
 from rpython.flowspace.argument import CallSpec
 from rpython.flowspace.model import (Constant, Variable, Block, Link,
     c_last_exception, const, FSException)
@@ -14,17 +16,19 @@
     recursively_flatten)
 from rpython.flowspace.specialcase import (rpython_print_item,
     rpython_print_newline)
+from rpython.flowspace.operation import op
 
+w_None = const(None)
 
 class FlowingError(Exception):
     """ Signals invalid RPython in the function being analysed"""
-    frame = None
+    ctx = None
 
     def __str__(self):
         msg = ["\n"]
         msg += map(str, self.args)
         msg += [""]
-        msg += source_lines(self.frame.graph, None, offset=self.frame.last_instr)
+        msg += source_lines(self.ctx.graph, None, offset=self.ctx.last_instr)
         return "\n".join(msg)
 
 class StopFlowing(Exception):
@@ -111,7 +115,7 @@
     def append(self, operation):
         raise NotImplementedError
 
-    def guessbool(self, frame, w_condition):
+    def guessbool(self, ctx, w_condition):
         raise AssertionError("cannot guessbool(%s)" % (w_condition,))
 
 
@@ -127,13 +131,13 @@
     def append(self, operation):
         self.crnt_block.operations.append(operation)
 
-    def guessbool(self, frame, w_condition):
+    def guessbool(self, ctx, w_condition):
         block = self.crnt_block
         vars = block.getvariables()
         links = []
         for case in [False, True]:
             egg = EggBlock(vars, block, case)
-            frame.pendingblocks.append(egg)
+            ctx.pendingblocks.append(egg)
             link = Link(vars, egg, case)
             links.append(link)
 
@@ -145,7 +149,7 @@
         # block.exits[True] = ifLink.
         raise StopFlowing
 
-    def guessexception(self, frame, *cases):
+    def guessexception(self, ctx, *cases):
         block = self.crnt_block
         bvars = vars = vars2 = block.getvariables()
         links = []
@@ -162,7 +166,7 @@
                 vars.extend([last_exc, last_exc_value])
                 vars2.extend([Variable(), Variable()])
             egg = EggBlock(vars2, block, case)
-            frame.pendingblocks.append(egg)
+            ctx.pendingblocks.append(egg)
             link = Link(vars, egg, case)
             if case is not None:
                 link.extravars(last_exception=last_exc, last_exc_value=last_exc_value)
@@ -193,14 +197,14 @@
                       [str(s) for s in self.listtoreplay[self.index:]]))
         self.index += 1
 
-    def guessbool(self, frame, w_condition):
+    def guessbool(self, ctx, w_condition):
         assert self.index == len(self.listtoreplay)
-        frame.recorder = self.nextreplayer
+        ctx.recorder = self.nextreplayer
         return self.booloutcome
 
-    def guessexception(self, frame, *classes):
+    def guessexception(self, ctx, *classes):
         assert self.index == len(self.listtoreplay)
-        frame.recorder = self.nextreplayer
+        ctx.recorder = self.nextreplayer
         outcome = self.booloutcome
         if outcome is not None:
             egg = self.nextreplayer.crnt_block
@@ -213,60 +217,55 @@
 # ____________________________________________________________
 
 _unary_ops = [
-    ('UNARY_POSITIVE', "pos"),
-    ('UNARY_NEGATIVE', "neg"),
-    ('UNARY_NOT', "not_"),
-    ('UNARY_CONVERT', "repr"),
-    ('UNARY_INVERT', "invert"),
+    ('UNARY_POSITIVE', op.pos),
+    ('UNARY_NEGATIVE', op.neg),
+    ('UNARY_CONVERT', op.repr),
+    ('UNARY_INVERT', op.invert),
 ]
 
-def unaryoperation(OPCODE, op):
+def unaryoperation(OPCODE, operation):
     def UNARY_OP(self, *ignored):
-        operation = getattr(self.space, op)
         w_1 = self.popvalue()
-        w_result = operation(w_1)
+        w_result = operation(w_1).eval(self)
         self.pushvalue(w_result)
-    UNARY_OP.unaryop = op
     UNARY_OP.func_name = OPCODE
     return UNARY_OP
 
 _binary_ops = [
-    ('BINARY_MULTIPLY', "mul"),
-    ('BINARY_TRUE_DIVIDE', "truediv"),
-    ('BINARY_FLOOR_DIVIDE', "floordiv"),
-    ('BINARY_DIVIDE', "div"),
-    ('BINARY_MODULO', "mod"),
-    ('BINARY_ADD', "add"),
-    ('BINARY_SUBTRACT', "sub"),
-    ('BINARY_SUBSCR', "getitem"),
-    ('BINARY_LSHIFT', "lshift"),
-    ('BINARY_RSHIFT', "rshift"),
-    ('BINARY_AND', "and_"),
-    ('BINARY_XOR', "xor"),
-    ('BINARY_OR', "or_"),
-    ('INPLACE_MULTIPLY', "inplace_mul"),
-    ('INPLACE_TRUE_DIVIDE', "inplace_truediv"),
-    ('INPLACE_FLOOR_DIVIDE', "inplace_floordiv"),
-    ('INPLACE_DIVIDE', "inplace_div"),
-    ('INPLACE_MODULO', "inplace_mod"),
-    ('INPLACE_ADD', "inplace_add"),
-    ('INPLACE_SUBTRACT', "inplace_sub"),
-    ('INPLACE_LSHIFT', "inplace_lshift"),
-    ('INPLACE_RSHIFT', "inplace_rshift"),
-    ('INPLACE_AND', "inplace_and"),
-    ('INPLACE_XOR', "inplace_xor"),
-    ('INPLACE_OR', "inplace_or"),
+    ('BINARY_MULTIPLY', op.mul),
+    ('BINARY_TRUE_DIVIDE', op.truediv),
+    ('BINARY_FLOOR_DIVIDE', op.floordiv),
+    ('BINARY_DIVIDE', op.div),
+    ('BINARY_MODULO', op.mod),
+    ('BINARY_ADD', op.add),
+    ('BINARY_SUBTRACT', op.sub),
+    ('BINARY_SUBSCR', op.getitem),
+    ('BINARY_LSHIFT', op.lshift),
+    ('BINARY_RSHIFT', op.rshift),
+    ('BINARY_AND', op.and_),
+    ('BINARY_XOR', op.xor),
+    ('BINARY_OR', op.or_),
+    ('INPLACE_MULTIPLY', op.inplace_mul),
+    ('INPLACE_TRUE_DIVIDE', op.inplace_truediv),
+    ('INPLACE_FLOOR_DIVIDE', op.inplace_floordiv),
+    ('INPLACE_DIVIDE', op.inplace_div),
+    ('INPLACE_MODULO', op.inplace_mod),
+    ('INPLACE_ADD', op.inplace_add),
+    ('INPLACE_SUBTRACT', op.inplace_sub),
+    ('INPLACE_LSHIFT', op.inplace_lshift),
+    ('INPLACE_RSHIFT', op.inplace_rshift),
+    ('INPLACE_AND', op.inplace_and),
+    ('INPLACE_XOR', op.inplace_xor),
+    ('INPLACE_OR', op.inplace_or),
 ]
 
-def binaryoperation(OPCODE, op):
+def binaryoperation(OPCODE, operation):
     """NOT_RPYTHON"""
-    def BINARY_OP(self, *ignored):
-        operation = getattr(self.space, op)
+    def BINARY_OP(self, _):
         w_2 = self.popvalue()
         w_1 = self.popvalue()
-        w_result = operation(w_1, w_2)
+        w_result = operation(w_1, w_2).eval(self)
         self.pushvalue(w_result)
-    BINARY_OP.binop = op
     BINARY_OP.func_name = OPCODE
     return BINARY_OP
 
@@ -305,14 +304,13 @@
     "cmp_exc_match",
     ]
 
-class FlowSpaceFrame(object):
+class FlowContext(object):
     opcode_method_names = host_bytecode_spec.method_names
 
-    def __init__(self, space, graph, code):
+    def __init__(self, graph, code):
         self.graph = graph
         func = graph.func
         self.pycode = code
-        self.space = space
         self.w_globals = Constant(func.func_globals)
         self.blockstack = []
 
@@ -321,7 +319,6 @@
         self.last_instr = 0
 
         self.init_locals_stack(code)
-        self.w_locals = None # XXX: only for compatibility with PyFrame
 
         self.joinpoints = {}
 
@@ -403,7 +400,7 @@
         return FrameState(data, self.blockstack[:], next_pos)
 
     def setstate(self, state):
-        """ Reset the frame to the given state. """
+        """ Reset the context to the given frame state. """
         data = state.mergeable[:]
         recursively_unflatten(data)
         self.restore_locals_stack(data[:-2])  # Nones == undefined locals
@@ -439,7 +436,7 @@
         if not exceptions:
             return
         if not force and not any(isinstance(block, (ExceptBlock, FinallyBlock))
-                for block in self.blockstack):
+                                 for block in self.blockstack):
             # The implicit exception wouldn't be caught and would later get
             # removed, so don't bother creating it.
             return
@@ -476,7 +473,7 @@
 
         except Raise as e:
             w_exc = e.w_exc
-            if w_exc.w_type == self.space.w_ImportError:
+            if w_exc.w_type == const(ImportError):
                 msg = 'import statement always raises %s' % e
                 raise ImportError(msg)
             link = Link([w_exc.w_type, w_exc.w_value], self.graph.exceptblock)
@@ -491,8 +488,8 @@
             self.recorder.crnt_block.closeblock(link)
 
         except FlowingError as exc:
-            if exc.frame is None:
-                exc.frame = self
+            if exc.ctx is None:
+                exc.ctx = self
             raise
 
         self.recorder = None
@@ -576,6 +573,11 @@
     def getname_w(self, index):
         return Constant(self.pycode.names[index])
 
+    def appcall(self, func, *args_w):
+        """Call an app-level RPython function directly"""
+        w_func = const(func)
+        return self.do_op(op.simple_call(w_func, *args_w))
+
     def BAD_OPCODE(self, _):
         raise FlowingError("This operation is not RPython")
 
@@ -585,38 +587,67 @@
     def CONTINUE_LOOP(self, startofloop):
         raise Continue(startofloop)
 
+    def not_(self, w_obj):
+        w_bool = op.bool(w_obj).eval(self)
+        return const(not self.guessbool(w_bool))
+
+    def UNARY_NOT(self, _):
+        w_obj = self.popvalue()
+        self.pushvalue(self.not_(w_obj))
+
     def cmp_lt(self, w_1, w_2):
-        return self.space.lt(w_1, w_2)
+        return op.lt(w_1, w_2).eval(self)
 
     def cmp_le(self, w_1, w_2):
-        return self.space.le(w_1, w_2)
+        return op.le(w_1, w_2).eval(self)
 
     def cmp_eq(self, w_1, w_2):
-        return self.space.eq(w_1, w_2)
+        return op.eq(w_1, w_2).eval(self)
 
     def cmp_ne(self, w_1, w_2):
-        return self.space.ne(w_1, w_2)
+        return op.ne(w_1, w_2).eval(self)
 
     def cmp_gt(self, w_1, w_2):
-        return self.space.gt(w_1, w_2)
+        return op.gt(w_1, w_2).eval(self)
 
     def cmp_ge(self, w_1, w_2):
-        return self.space.ge(w_1, w_2)


More information about the pypy-commit mailing list