[pypy-commit] pypy default: merge heads

bivab noreply at buildbot.pypy.org
Thu May 16 14:45:55 CEST 2013


Author: David Schneider <david.schneider at picle.org>
Branch: 
Changeset: r64227:f73088779125
Date: 2013-05-16 14:45 +0200
http://bitbucket.org/pypy/pypy/changeset/f73088779125/

Log:	merge heads

diff too long, truncating to 2000 out of 2471 lines

diff --git a/lib-python/2.7/socket.py b/lib-python/2.7/socket.py
--- a/lib-python/2.7/socket.py
+++ b/lib-python/2.7/socket.py
@@ -324,7 +324,12 @@
                 if self._close:
                     self._sock.close()
                 else:
-                    self._sock._decref_socketios()
+                    try:
+                        self._sock._decref_socketios()
+                    except AttributeError:
+                        pass  # bah, someone built a _fileobject manually
+                              # with some unexpected replacement of the
+                              # _socketobject class
             self._sock = None
 
     def __del__(self):
diff --git a/lib-python/2.7/test/test_codecs.py b/lib-python/2.7/test/test_codecs.py
--- a/lib-python/2.7/test/test_codecs.py
+++ b/lib-python/2.7/test/test_codecs.py
@@ -2,7 +2,11 @@
 import unittest
 import codecs
 import locale
-import sys, StringIO, _testcapi
+import sys, StringIO
+try:
+    import _testcapi
+except ImportError:
+    _testcapi = None
 
 class Queue(object):
     """
@@ -1387,7 +1391,7 @@
                     decodedresult += reader.read()
                 self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding))
 
-            if encoding not in broken_incremental_coders:
+            if encoding not in broken_incremental_coders and _testcapi:
                 # check incremental decoder/encoder (fetched via the Python
                 # and C API) and iterencode()/iterdecode()
                 try:
diff --git a/lib-python/2.7/test/test_traceback.py b/lib-python/2.7/test/test_traceback.py
--- a/lib-python/2.7/test/test_traceback.py
+++ b/lib-python/2.7/test/test_traceback.py
@@ -1,6 +1,9 @@
 """Test cases for traceback module"""
 
-from _testcapi import traceback_print
+try:
+    from _testcapi import traceback_print
+except ImportError:
+    traceback_print = None
 from StringIO import StringIO
 import sys
 import unittest
@@ -176,6 +179,8 @@
 class TracebackFormatTests(unittest.TestCase):
 
     def test_traceback_format(self):
+        if traceback_print is None:
+            raise unittest.SkipTest('Requires _testcapi')
         try:
             raise KeyError('blah')
         except KeyError:
diff --git a/lib-python/2.7/test/test_unicode.py b/lib-python/2.7/test/test_unicode.py
--- a/lib-python/2.7/test/test_unicode.py
+++ b/lib-python/2.7/test/test_unicode.py
@@ -1609,7 +1609,10 @@
         self.assertEqual("{}".format(u), '__unicode__ overridden')
 
     def test_encode_decimal(self):
-        from _testcapi import unicode_encodedecimal
+        try:
+            from _testcapi import unicode_encodedecimal
+        except ImportError:
+            raise unittest.SkipTest('Requires _testcapi')
         self.assertEqual(unicode_encodedecimal(u'123'),
                          b'123')
         self.assertEqual(unicode_encodedecimal(u'\u0663.\u0661\u0664'),
diff --git a/lib-python/conftest.py b/lib-python/conftest.py
--- a/lib-python/conftest.py
+++ b/lib-python/conftest.py
@@ -130,7 +130,7 @@
     RegrTest('test_bz2.py', usemodules='bz2'),
     RegrTest('test_calendar.py'),
     RegrTest('test_call.py', core=True),
-    RegrTest('test_capi.py'),
+    RegrTest('test_capi.py', usemodules='cpyext'),
     RegrTest('test_cd.py'),
     RegrTest('test_cfgparser.py'),
     RegrTest('test_cgi.py'),
@@ -177,7 +177,7 @@
     RegrTest('test_cprofile.py'),
     RegrTest('test_crypt.py', usemodules='crypt'),
     RegrTest('test_csv.py', usemodules='_csv'),
-    RegrTest('test_ctypes.py', usemodules="_rawffi thread"),
+    RegrTest('test_ctypes.py', usemodules="_rawffi thread cpyext"),
     RegrTest('test_curses.py'),
     RegrTest('test_datetime.py', usemodules='binascii struct'),
     RegrTest('test_dbm.py'),
diff --git a/lib_pypy/_testcapi.py b/lib_pypy/_testcapi.py
--- a/lib_pypy/_testcapi.py
+++ b/lib_pypy/_testcapi.py
@@ -54,4 +54,9 @@
     fp, filename, description = imp.find_module('_testcapi', path=[output_dir])
     imp.load_module('_testcapi', fp, filename, description)
 
-compile_shared()
+try:
+    import cpyext
+except ImportError:
+    raise ImportError("No module named '_testcapi'")
+else:
+    compile_shared()
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
@@ -7,3 +7,15 @@
 
 .. branch: numpy-pickle
 Pickling of numpy arrays and dtypes (including record dtypes)
+
+.. branch: remove-array-smm
+Remove multimethods in the arraymodule
+
+.. branch: callback-stacklet
+Fixed bug when switching stacklets from a C callback
+
+.. branch: remove-set-smm
+Remove multi-methods on sets
+
+.. branch: numpy-subarrays
+Implement subarrays for numpy
diff --git a/pypy/module/_ffi/test/test_funcptr.py b/pypy/module/_ffi/test/test_funcptr.py
--- a/pypy/module/_ffi/test/test_funcptr.py
+++ b/pypy/module/_ffi/test/test_funcptr.py
@@ -74,9 +74,9 @@
         from _ffi import CDLL, types
         # this should return *all* loaded libs, dlopen(NULL)
         dll = CDLL(None)
-        # Assume CPython, or PyPy compiled with cpyext
-        res = dll.getfunc('Py_IsInitialized', [], types.slong)()
-        assert res == 1
+        # libm should be loaded
+        res = dll.getfunc('sqrt', [types.double], types.double)(1.0)
+        assert res == 1.0
 
     def test_callfunc(self):
         from _ffi import CDLL, types
@@ -139,7 +139,7 @@
 
     def test_pointer_args(self):
         """
-            extern int dummy; // defined in test_void_result 
+            extern int dummy; // defined in test_void_result
             DLLEXPORT int* get_dummy_ptr() { return &dummy; }
             DLLEXPORT void set_val_to_ptr(int* ptr, int val) { *ptr = val; }
         """
@@ -158,7 +158,7 @@
 
     def test_convert_pointer_args(self):
         """
-            extern int dummy; // defined in test_void_result 
+            extern int dummy; // defined in test_void_result
             DLLEXPORT int* get_dummy_ptr(); // defined in test_pointer_args
             DLLEXPORT void set_val_to_ptr(int* ptr, int val); // ditto
         """
@@ -170,7 +170,7 @@
             def _as_ffi_pointer_(self, ffitype):
                 assert ffitype is types.void_p
                 return self.value
-        
+
         libfoo = CDLL(self.libfoo_name)
         get_dummy = libfoo.getfunc('get_dummy', [], types.sint)
         get_dummy_ptr = libfoo.getfunc('get_dummy_ptr', [], types.void_p)
@@ -259,7 +259,7 @@
 
     def test_typed_pointer_args(self):
         """
-            extern int dummy; // defined in test_void_result 
+            extern int dummy; // defined in test_void_result
             DLLEXPORT int* get_dummy_ptr(); // defined in test_pointer_args
             DLLEXPORT void set_val_to_ptr(int* ptr, int val); // ditto
         """
@@ -551,7 +551,7 @@
         from _ffi import CDLL, types
         libfoo = CDLL(self.libfoo_name)
         raises(TypeError, "libfoo.getfunc('sum_xy', [types.void], types.sint)")
-        
+
     def test_OSError_loading(self):
         from _ffi import CDLL, types
         raises(OSError, "CDLL('I do not exist')")
@@ -606,7 +606,7 @@
         from _rawffi import FUNCFLAG_STDCALL
         libm = CDLL(self.libm_name)
         pow_addr = libm.getaddressindll('pow')
-        wrong_pow = FuncPtr.fromaddr(pow_addr, 'pow', 
+        wrong_pow = FuncPtr.fromaddr(pow_addr, 'pow',
                 [types.double, types.double], types.double, FUNCFLAG_STDCALL)
         try:
             wrong_pow(2, 3) == 8
@@ -622,7 +622,7 @@
         from _rawffi import FUNCFLAG_STDCALL
         kernel = WinDLL('Kernel32.dll')
         sleep_addr = kernel.getaddressindll('Sleep')
-        sleep = FuncPtr.fromaddr(sleep_addr, 'sleep', [types.uint], 
+        sleep = FuncPtr.fromaddr(sleep_addr, 'sleep', [types.uint],
                             types.void, FUNCFLAG_STDCALL)
         sleep(10)
 
diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -100,11 +100,11 @@
         return space.w_True
     if comp_op == LT or comp_op == LE:
         if arr1.len < arr2.len:
-            return space.w_False
+            return space.w_True
+        return space.w_False
+    if arr1.len > arr2.len:
         return space.w_True
-    if arr1.len > arr2.len:
-        return space.w_False
-    return space.w_True
+    return space.w_False
 
 UNICODE_ARRAY = lltype.Ptr(lltype.Array(lltype.UniChar,
                                         hints={'nolength': True}))
diff --git a/pypy/module/array/test/test_array.py b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -552,6 +552,15 @@
                 assert (a >= c) is False
                 assert (c >= a) is True
 
+        a = self.array('i', [-1, 0, 1, 42, 0x7f])
+        assert not a == 2*a
+        assert a != 2*a
+        assert a < 2*a
+        assert a <= 2*a
+        assert not a > 2*a
+        assert not a >= 2*a
+
+
     def test_reduce(self):
         import pickle
         a = self.array('i', [1, 2, 3])
diff --git a/pypy/module/micronumpy/compile.py b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -14,6 +14,7 @@
 from pypy.module.micronumpy.interp_arrayops import where
 from pypy.module.micronumpy import interp_ufuncs
 from rpython.rlib.objectmodel import specialize, instantiate
+from rpython.rlib.nonconst import NonConstant
 
 
 class BogusBytecode(Exception):
@@ -40,6 +41,10 @@
 TWO_ARG_FUNCTIONS = ["dot", 'take']
 THREE_ARG_FUNCTIONS = ['where']
 
+class W_TypeObject(W_Root):
+    def __init__(self, name):
+        self.name = name
+
 class FakeSpace(object):
     w_ValueError = "ValueError"
     w_TypeError = "TypeError"
@@ -48,17 +53,17 @@
     w_NotImplementedError = "NotImplementedError"
     w_None = None
 
-    w_bool = "bool"
-    w_int = "int"
-    w_float = "float"
-    w_list = "list"
-    w_long = "long"
-    w_tuple = 'tuple'
-    w_slice = "slice"
-    w_str = "str"
-    w_unicode = "unicode"
-    w_complex = "complex"
-    w_dict = "dict"
+    w_bool = W_TypeObject("bool")
+    w_int = W_TypeObject("int")
+    w_float = W_TypeObject("float")
+    w_list = W_TypeObject("list")
+    w_long = W_TypeObject("long")
+    w_tuple = W_TypeObject('tuple')
+    w_slice = W_TypeObject("slice")
+    w_str = W_TypeObject("str")
+    w_unicode = W_TypeObject("unicode")
+    w_complex = W_TypeObject("complex")
+    w_dict = W_TypeObject("dict")
 
     def __init__(self):
         """NOT_RPYTHON"""
@@ -73,6 +78,13 @@
     def issequence_w(self, w_obj):
         return isinstance(w_obj, ListObject) or isinstance(w_obj, W_NDimArray)
 
+    def len(self, w_obj):
+        assert isinstance(w_obj, ListObject)
+        return self.wrap(len(w_obj.items))
+
+    def getattr(self, w_obj, w_attr):
+        return StringObject(NonConstant('foo'))
+
     def isinstance_w(self, w_obj, w_tp):
         return w_obj.tp == w_tp
 
diff --git a/pypy/module/sys/system.py b/pypy/module/sys/system.py
--- a/pypy/module/sys/system.py
+++ b/pypy/module/sys/system.py
@@ -1,6 +1,6 @@
 """Information about the current system."""
 from pypy.interpreter import gateway
-from rpython.rlib import rfloat, rbigint
+from rpython.rlib import rbigint, rfloat
 from rpython.rtyper.lltypesystem import rffi
 
 
@@ -47,7 +47,6 @@
     return space.call_function(w_float_info, space.newtuple(info_w))
 
 def get_long_info(space):
-    #assert rbigint.SHIFT == 31
     bits_per_digit = rbigint.SHIFT
     sizeof_digit = rffi.sizeof(rbigint.STORE_TYPE)
     info_w = [
@@ -58,7 +57,4 @@
     return space.call_function(w_long_info, space.newtuple(info_w))
 
 def get_float_repr_style(space):
-    if rfloat.USE_SHORT_FLOAT_REPR:
-        return space.wrap("short")
-    else:
-        return space.wrap("legacy")
+    return space.wrap("short" if rfloat.USE_SHORT_FLOAT_REPR else "legacy")
diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -55,6 +55,10 @@
         from rpython.rlib.rbigint import rbigint
         return rbigint.fromint(NonConstant(42))
 
+class W_MyListObj(W_MyObject):
+    def append(self, w_other):
+        pass
+
 class W_MyType(W_MyObject):
     def __init__(self):
         self.mro_w = [w_some_obj(), w_some_obj()]
@@ -106,6 +110,10 @@
     def __init__(self, config=None):
         self._seen_extras = []
         ObjSpace.__init__(self, config=config)
+        self.setup()
+
+    def _freeze_(self):
+        return True
 
     def float_w(self, w_obj):
         is_root(w_obj)
@@ -131,7 +139,7 @@
     def newlist(self, list_w):
         for w_x in list_w:
             is_root(w_x)
-        return w_some_obj()
+        return W_MyListObj()
 
     def newslice(self, w_start, w_end, w_step):
         is_root(w_start)
@@ -316,38 +324,36 @@
         t.buildrtyper().specialize()
         t.checkgraphs()
 
+    def setup(space):
+        for name in (ObjSpace.ConstantTable +
+                     ObjSpace.ExceptionTable +
+                     ['int', 'str', 'float', 'long', 'tuple', 'list',
+                      'dict', 'unicode', 'complex', 'slice', 'bool',
+                      'basestring', 'object', 'bytearray']):
+            setattr(space, 'w_' + name, w_some_obj())
+        space.w_type = w_some_type()
+        #
+        for (name, _, arity, _) in ObjSpace.MethodTable:
+            if name == 'type':
+                continue
+            args = ['w_%d' % i for i in range(arity)]
+            params = args[:]
+            d = {'is_root': is_root,
+                 'w_some_obj': w_some_obj}
+            if name in ('get',):
+                params[-1] += '=None'
+            exec compile2("""\
+                def meth(%s):
+                    %s
+                    return w_some_obj()
+            """ % (', '.join(params),
+                   '; '.join(['is_root(%s)' % arg for arg in args]))) in d
+            meth = func_with_new_name(d['meth'], name)
+            setattr(space, name, meth)
+        #
+        for name in ObjSpace.IrregularOpTable:
+            assert hasattr(space, name)    # missing?
 
-def setup():
-    for name in (ObjSpace.ConstantTable +
-                 ObjSpace.ExceptionTable +
-                 ['int', 'str', 'float', 'long', 'tuple', 'list',
-                  'dict', 'unicode', 'complex', 'slice', 'bool',
-                  'basestring', 'object', 'bytearray']):
-        setattr(FakeObjSpace, 'w_' + name, w_some_obj())
-    FakeObjSpace.w_type = w_some_type()
-    #
-    for (name, _, arity, _) in ObjSpace.MethodTable:
-        if name == 'type':
-            continue
-        args = ['w_%d' % i for i in range(arity)]
-        params = args[:]
-        d = {'is_root': is_root,
-             'w_some_obj': w_some_obj}
-        if name in ('get',):
-            params[-1] += '=None'
-        exec compile2("""\
-            def meth(self, %s):
-                %s
-                return w_some_obj()
-        """ % (', '.join(params),
-               '; '.join(['is_root(%s)' % arg for arg in args]))) in d
-        meth = func_with_new_name(d['meth'], name)
-        setattr(FakeObjSpace, name, meth)
-    #
-    for name in ObjSpace.IrregularOpTable:
-        assert hasattr(FakeObjSpace, name)    # missing?
-
-setup()
 
 # ____________________________________________________________
 
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
@@ -1,8 +1,8 @@
 import py, sys
 from pypy.objspace.std.model import registerimplementation, W_Object
 from pypy.objspace.std.register_all import register_all
-from pypy.objspace.std.settype import set_typedef as settypedef
-from pypy.objspace.std.frozensettype import frozenset_typedef as frozensettypedef
+from pypy.objspace.std.setobject import set_typedef as settypedef
+from pypy.objspace.std.setobject import frozenset_typedef as frozensettypedef
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.signature import Signature
 
diff --git a/pypy/objspace/std/frozensettype.py b/pypy/objspace/std/frozensettype.py
deleted file mode 100644
--- a/pypy/objspace/std/frozensettype.py
+++ /dev/null
@@ -1,55 +0,0 @@
-from pypy.interpreter import gateway
-from pypy.interpreter.error import OperationError
-from pypy.objspace.std.register_all import register_all
-from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
-
-
-frozenset_copy                  = SMM('copy', 1,
-                                      doc='Return a shallow copy of a set.')
-frozenset_difference            = SMM('difference', 1, varargs_w=True,
-                                      doc='Return a new set with elements in'
-                                          ' the set that are not in the others.')
-frozenset_intersection          = SMM('intersection', 1, varargs_w=True,
-                                      doc='Return a new set with elements common'
-                                          ' to the set and all others.')
-frozenset_issubset              = SMM('issubset', 2,
-                                      doc='Report whether another set contains'
-                                          ' this set.')
-frozenset_issuperset            = SMM('issuperset', 2,
-                                      doc='Report whether this set contains'
-                                          ' another set.')
-frozenset_symmetric_difference  = SMM('symmetric_difference', 2,
-                                      doc='Return the symmetric difference of'
-                                          ' two sets as a new set.\n\n(i.e.'
-                                          ' all elements that are in exactly'
-                                          ' one of the sets.)')
-frozenset_union                 = SMM('union', 1, varargs_w=True,
-                                      doc='Return a new set with elements'
-                                          ' from the set and all others.')
-frozenset_reduce                = SMM('__reduce__',1,
-                                      doc='Return state information for'
-                                          ' pickling.')
-# 2.6 methods
-frozenset_isdisjoint            = SMM('isdisjoint', 2,
-                                      doc='Return True if two sets have a'
-                                          ' null intersection.')
-
-register_all(vars(), globals())
-
-def descr__frozenset__new__(space, w_frozensettype, w_iterable=None):
-    from pypy.objspace.std.setobject import W_FrozensetObject
-    if (space.is_w(w_frozensettype, space.w_frozenset) and
-        w_iterable is not None and type(w_iterable) is W_FrozensetObject):
-        return w_iterable
-    w_obj = space.allocate_instance(W_FrozensetObject, w_frozensettype)
-    W_FrozensetObject.__init__(w_obj, space, w_iterable)
-    return w_obj
-
-frozenset_typedef = StdTypeDef("frozenset",
-    __doc__ = """frozenset(iterable) --> frozenset object
-
-Build an immutable unordered collection.""",
-    __new__ = gateway.interp2app(descr__frozenset__new__),
-    )
-
-frozenset_typedef.registermethods(globals())
diff --git a/pypy/objspace/std/model.py b/pypy/objspace/std/model.py
--- a/pypy/objspace/std/model.py
+++ b/pypy/objspace/std/model.py
@@ -38,8 +38,6 @@
             from pypy.objspace.std.inttype    import int_typedef
             from pypy.objspace.std.floattype  import float_typedef
             from pypy.objspace.std.complextype  import complex_typedef
-            from pypy.objspace.std.settype import set_typedef
-            from pypy.objspace.std.frozensettype import frozenset_typedef
             from pypy.objspace.std.tupletype  import tuple_typedef
             from pypy.objspace.std.listobject   import list_typedef
             from pypy.objspace.std.dicttype   import dict_typedef
@@ -63,10 +61,10 @@
         from pypy.objspace.std import intobject
         from pypy.objspace.std import floatobject
         from pypy.objspace.std import complexobject
-        from pypy.objspace.std import setobject
         from pypy.objspace.std import tupleobject
         from pypy.objspace.std import listobject
         from pypy.objspace.std import dictmultiobject
+        from pypy.objspace.std import setobject
         from pypy.objspace.std import stringobject
         from pypy.objspace.std import bytearrayobject
         from pypy.objspace.std import typeobject
@@ -81,6 +79,11 @@
 
         import pypy.objspace.std.marshal_impl # install marshal multimethods
 
+        # not-multimethod based types
+
+        self.pythontypes.append(setobject.W_SetObject.typedef)
+        self.pythontypes.append(setobject.W_FrozensetObject.typedef)
+
         # the set of implementation types
         self.typeorder = {
             objectobject.W_ObjectObject: [],
@@ -100,10 +103,6 @@
             longobject.W_LongObject: [],
             noneobject.W_NoneObject: [],
             complexobject.W_ComplexObject: [],
-            setobject.W_BaseSetObject: [],
-            setobject.W_SetObject: [],
-            setobject.W_FrozensetObject: [],
-            setobject.W_SetIterObject: [],
             iterobject.W_SeqIterObject: [],
             iterobject.W_FastListIterObject: [],
             iterobject.W_FastTupleIterObject: [],
@@ -192,12 +191,7 @@
             (complexobject.W_ComplexObject,
                     complexobject.delegate_Float2Complex),
             ]
-        self.typeorder[setobject.W_SetObject] += [
-            (setobject.W_BaseSetObject, None)
-            ]
-        self.typeorder[setobject.W_FrozensetObject] += [
-            (setobject.W_BaseSetObject, None)
-            ]
+
         self.typeorder[stringobject.W_StringObject] += [
             (unicodeobject.W_UnicodeObject, unicodeobject.delegate_String2Unicode),
             ]
@@ -339,8 +333,9 @@
             s += ' instance of %s' % self.w__class__
         return '<%s>' % s
 
-    def unwrap(w_self, space):
-        raise UnwrapError, 'cannot unwrap %r' % (w_self,)
+    def unwrap(self, space):
+        raise UnwrapError('cannot unwrap %r' % self)
+
 
 class UnwrapError(Exception):
     pass
@@ -405,7 +400,7 @@
         mm.dispatch_tree = merge(self.dispatch_tree, other.dispatch_tree)
         return mm
 
-NOT_MULTIMETHODS = dict.fromkeys(
+NOT_MULTIMETHODS = set(
     ['delattr', 'delete', 'get', 'id', 'inplace_div', 'inplace_floordiv',
      'inplace_lshift', 'inplace_mod', 'inplace_pow', 'inplace_rshift',
      'inplace_truediv', 'is_', 'set', 'setattr', 'type', 'userdel',
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
@@ -1,13 +1,9 @@
-from pypy.objspace.std.model import registerimplementation, W_Object
-from pypy.objspace.std.register_all import register_all
+from pypy.interpreter import gateway
 from pypy.interpreter.error import OperationError
-from pypy.interpreter import gateway
-from pypy.objspace.std.settype import set_typedef as settypedef
-from pypy.objspace.std.frozensettype import frozenset_typedef as frozensettypedef
 from pypy.interpreter.signature import Signature
-from pypy.interpreter.generator import GeneratorIterator
-from pypy.objspace.std.listobject import W_ListObject
+from pypy.interpreter.baseobjspace import W_Root
 from pypy.objspace.std.intobject import W_IntObject
+from pypy.objspace.std.stdtypedef import StdTypeDef
 from pypy.objspace.std.stringobject import W_StringObject
 from pypy.objspace.std.unicodeobject import W_UnicodeObject
 
@@ -15,20 +11,13 @@
 from rpython.rlib.rarithmetic import intmask, r_uint
 from rpython.rlib import rerased, jit
 
+
 UNROLL_CUTOFF = 5
 
-class W_BaseSetObject(W_Object):
+
+class W_BaseSetObject(W_Root):
     typedef = None
 
-    # make sure that Base is used for Set and Frozenset in multimethod
-    # declarations
-    @classmethod
-    def is_implementation_for(cls, typedef):
-        if typedef is frozensettypedef or typedef is settypedef:
-            assert cls is W_BaseSetObject
-            return True
-        return False
-
     def __init__(w_self, space, w_iterable=None):
         """Initialize the set by taking ownership of 'setdata'."""
         w_self.space = space
@@ -66,7 +55,6 @@
 
     # _____________ strategy methods ________________
 
-
     def clear(self):
         """ Removes all elements from the set. """
         self.strategy.clear(self)
@@ -164,9 +152,355 @@
         """ Removes an arbitrary element from the set. May raise KeyError if set is empty."""
         return self.strategy.popitem(self)
 
+    # app-level operations
+
+    def descr_init(self, space, __args__):
+        w_iterable, = __args__.parse_obj(
+                None, 'set',
+                init_signature,
+                init_defaults)
+        _initialize_set(space, self, w_iterable)
+
+    def descr_repr(self, space):
+        ec = space.getexecutioncontext()
+        w_currently_in_repr = ec._py_repr
+        if w_currently_in_repr is None:
+            w_currently_in_repr = ec._py_repr = space.newdict()
+        return setrepr(space, w_currently_in_repr, self)
+
+    def descr_cmp(self, space, w_other):
+        # hack hack until we get the expected result
+        raise OperationError(space.w_TypeError,
+                space.wrap('cannot compare sets using cmp()'))
+
+    def descr_eq(self, space, w_other):
+        if isinstance(w_other, W_BaseSetObject):
+            return space.wrap(self.equals(w_other))
+
+        if not space.isinstance_w(w_other, space.w_set):
+            return space.w_False
+
+        # XXX there is no test_buildinshortcut.py
+        # tested in test_buildinshortcut.py
+        # XXX do not make new setobject here
+        w_other_as_set = self._newobj(space, w_other)
+        return space.wrap(self.equals(w_other_as_set))
+
+    def descr_ne(self, space, w_other):
+        if isinstance(w_other, W_BaseSetObject):
+            return space.wrap(not self.equals(w_other))
+
+        if not space.isinstance_w(w_other, space.w_set):
+            return space.w_True
+
+        # XXX this is not tested
+        w_other_as_set = self._newobj(space, w_other)
+        return space.wrap(not self.equals(w_other_as_set))
+
+    # automatic registration of "lt(x, y)" as "not ge(y, x)" would not give the
+    # correct answer here!
+    def descr_lt(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            raise OperationError(self.space.w_TypeError,
+                                 self.space.wrap('can only compare to a set'))
+
+        if self.length() >= w_other.length():
+            return space.w_False
+        else:
+            return self.descr_issubset(space, w_other)
+
+    def descr_le(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            raise OperationError(self.space.w_TypeError,
+                                 self.space.wrap('can only compare to a set'))
+
+        if self.length() > w_other.length():
+            return space.w_False
+        return space.wrap(self.issubset(w_other))
+
+    def descr_gt(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            raise OperationError(self.space.w_TypeError,
+                                 self.space.wrap('can only compare to a set'))
+
+        if self.length() <= w_other.length():
+            return space.w_False
+        else:
+            return self.descr_issuperset(space, w_other)
+
+    def descr_ge(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            raise OperationError(self.space.w_TypeError,
+                                 self.space.wrap('can only compare to a set'))
+
+        if self.length() < w_other.length():
+            return space.w_False
+        return space.wrap(w_other.issubset(self))
+
+    def descr_len(self, space):
+        return space.newint(self.length())
+
+    def descr_iter(self, space):
+        return W_SetIterObject(space, self.iter())
+
+    def descr_contains(self, space, w_other):
+        try:
+            return space.newbool(self.has_key(w_other))
+        except OperationError, e:
+            if e.match(space, space.w_TypeError):
+                w_f = _convert_set_to_frozenset(space, w_other)
+                if w_f is not None:
+                    return space.newbool(self.has_key(w_f))
+            raise
+
+    def descr_sub(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            return space.w_NotImplemented
+        return self.difference(w_other)
+
+    def descr_and(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            return space.w_NotImplemented
+        return self.intersect(w_other)
+
+    def descr_or(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            return space.w_NotImplemented
+        w_copy = self.copy_real()
+        w_copy.update(w_other)
+        return w_copy
+
+    def descr_xor(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            return space.w_NotImplemented
+        return self.symmetric_difference(w_other)
+
+    def descr_inplace_sub(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            return space.w_NotImplemented
+        self.difference_update(w_other)
+        return self
+
+    def descr_inplace_and(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            return space.w_NotImplemented
+        self.intersect_update(w_other)
+        return self
+
+    def descr_inplace_or(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            return space.w_NotImplemented
+        self.update(w_other)
+        return self
+
+    def descr_inplace_xor(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            return space.w_NotImplemented
+        self.descr_symmetric_difference_update(space, w_other)
+        return self
+
+    def descr_copy(self, space):
+        """Return a shallow copy of a set."""
+        if type(self) is W_FrozensetObject:
+            return self
+        return self.copy_real()
+
+    @gateway.unwrap_spec(others_w='args_w')
+    def descr_difference(self, space, others_w):
+        """Return a new set with elements in the set that are not in the
+        others."""
+        result = self.copy_real()
+        result.descr_difference_update(space, others_w)
+        return result
+
+    @gateway.unwrap_spec(others_w='args_w')
+    def descr_intersection(self, space, others_w):
+        """Return a new set with elements common to the set and all others."""
+        #XXX find smarter implementations
+        others_w = [self] + others_w
+
+        # find smallest set in others_w to reduce comparisons
+        startindex, startlength = 0, -1
+        for i in range(len(others_w)):
+            w_other = others_w[i]
+            try:
+                length = space.int_w(space.len(w_other))
+            except OperationError, e:
+                if (e.match(space, space.w_TypeError) or
+                    e.match(space, space.w_AttributeError)):
+                    continue
+                raise
+
+            if startlength == -1 or length < startlength:
+                startindex = i
+                startlength = length
+
+        others_w[startindex], others_w[0] = others_w[0], others_w[startindex]
+
+        result = self._newobj(space, others_w[0])
+        for i in range(1,len(others_w)):
+            w_other = others_w[i]
+            if isinstance(w_other, W_BaseSetObject):
+                result.intersect_update(w_other)
+            else:
+                w_other_as_set = self._newobj(space, w_other)
+                result.intersect_update(w_other_as_set)
+        return result
+
+    def descr_issubset(self, space, w_other):
+        """Report whether another set contains this set."""
+        if space.is_w(self, w_other):
+            return space.w_True
+
+        if isinstance(w_other, W_BaseSetObject):
+            if self.length() > w_other.length():
+                return space.w_False
+            return space.wrap(self.issubset(w_other))
+
+        w_other_as_set = self._newobj(space, w_other)
+        if self.length() > w_other_as_set.length():
+            return space.w_False
+        return space.wrap(self.issubset(w_other_as_set))
+
+    def descr_issuperset(self, space, w_other):
+        """Report whether this set contains another set."""
+        if space.is_w(self, w_other):
+            return space.w_True
+
+        if isinstance(w_other, W_BaseSetObject):
+            if self.length() < w_other.length():
+                return space.w_False
+            return space.wrap(w_other.issubset(self))
+
+        w_other_as_set = self._newobj(space, w_other)
+        if self.length() < w_other_as_set.length():
+            return space.w_False
+        return space.wrap(w_other_as_set.issubset(self))
+
+    def descr_symmetric_difference(self, space, w_other):
+        """Return the symmetric difference of two sets as a new set.
+
+        (i.e. all elements that are in exactly one of the sets.)"""
+
+        if isinstance(w_other, W_BaseSetObject):
+            return self.symmetric_difference(w_other)
+
+        w_other_as_set = self._newobj(space, w_other)
+        return self.symmetric_difference(w_other_as_set)
+
+    @gateway.unwrap_spec(others_w='args_w')
+    def descr_union(self, space, others_w):
+        """Return a new set with elements from the set and all others."""
+        result = self.copy_real()
+        for w_other in others_w:
+            if isinstance(w_other, W_BaseSetObject):
+                result.update(w_other)
+            else:
+                for w_key in space.listview(w_other):
+                    result.add(w_key)
+        return result
+
+    def descr_reduce(self, space):
+        """Return state information for pickling."""
+        return setreduce(space, self)
+
+    def descr_isdisjoint(self, space, w_other):
+        """Return True if two sets have a null intersection."""
+
+        if isinstance(w_other, W_BaseSetObject):
+            return space.newbool(self.isdisjoint(w_other))
+
+        #XXX may be optimized when other strategies are added
+        for w_key in space.listview(w_other):
+            if self.has_key(w_key):
+                return space.w_False
+        return space.w_True
+
+    def descr_add(self, space, w_other):
+        """Add an element to a set.
+
+        This has no effect if the element is already present."""
+        self.add(w_other)
+
+    def descr_clear(self, space):
+        """Remove all elements from this set."""
+        self.clear()
+
+    @gateway.unwrap_spec(others_w='args_w')
+    def descr_difference_update(self, space, others_w):
+        """Update the set, removing elements found in others."""
+        for w_other in others_w:
+            if isinstance(w_other, W_BaseSetObject):
+                self.difference_update(w_other)
+            else:
+                w_other_as_set = self._newobj(space, w_other)
+                self.difference_update(w_other_as_set)
+
+    def _discard_from_set(self, space, w_item):
+        """
+        Discard an element from a set, with automatic conversion to
+        frozenset if the argument is a set.
+        Returns True if successfully removed.
+        """
+        try:
+            deleted = self.remove(w_item)
+        except OperationError, e:
+            if not e.match(space, space.w_TypeError):
+                raise
+            else:
+                w_f = _convert_set_to_frozenset(space, w_item)
+                if w_f is None:
+                    raise
+                deleted = self.remove(w_f)
+
+        if self.length() == 0:
+            self.switch_to_empty_strategy()
+        return deleted
+
+    def descr_discard(self, space, w_item):
+        """Remove an element from a set if it is a member.
+
+        If the element is not a member, do nothing."""
+        self._discard_from_set(space, w_item)
+
+    @gateway.unwrap_spec(others_w='args_w')
+    def descr_intersection_update(self, space, others_w):
+        """Update the set, keeping only elements found in it and all others."""
+        result = self.descr_intersection(space, others_w)
+        self.strategy = result.strategy
+        self.sstorage = result.sstorage
+
+    def descr_pop(self, space):
+        """Remove and return an arbitrary set element."""
+        return self.popitem()
+
+    def descr_remove(self, space, w_item):
+        """Remove an element from a set; it must be a member.
+
+        If the element is not a member, raise a KeyError."""
+        if not self._discard_from_set(space, w_item):
+            space.raise_key_error(w_item)
+
+    def descr_symmetric_difference_update(self, space, w_other):
+        """Update a set with the symmetric difference of itself and another."""
+        if isinstance(w_other, W_BaseSetObject):
+            self.symmetric_difference_update(w_other)
+            return
+        w_other_as_set = self._newobj(space, w_other)
+        self.symmetric_difference_update(w_other_as_set)
+
+    @gateway.unwrap_spec(others_w='args_w')
+    def descr_update(self, space, others_w):
+        """Update a set with the union of itself and another."""
+        for w_other in others_w:
+            if isinstance(w_other, W_BaseSetObject):
+                self.update(w_other)
+            else:
+                for w_key in space.listview(w_other):
+                    self.add(w_key)
+
+
 class W_SetObject(W_BaseSetObject):
-    from pypy.objspace.std.settype import set_typedef as typedef
-
     def _newobj(w_self, space, w_iterable):
         """Make a new set by taking ownership of 'w_iterable'."""
         if type(w_self) is W_SetObject:
@@ -176,8 +510,71 @@
         W_SetObject.__init__(w_obj, space, w_iterable)
         return w_obj
 
+    @staticmethod
+    def descr_new(space, w_settype, __args__):
+        w_obj = space.allocate_instance(W_SetObject, w_settype)
+        W_SetObject.__init__(w_obj, space)
+        return w_obj
+
+W_SetObject.typedef = StdTypeDef("set",
+    __doc__ = """set(iterable) --> set object
+
+Build an unordered collection.""",
+    __new__ = gateway.interp2app(W_SetObject.descr_new),
+    __init__ = gateway.interp2app(W_BaseSetObject.descr_init),
+    __repr__ = gateway.interp2app(W_BaseSetObject.descr_repr),
+    __hash__ = None,
+    __cmp__ = gateway.interp2app(W_BaseSetObject.descr_cmp),
+
+    # comparison operators
+    __eq__ = gateway.interp2app(W_BaseSetObject.descr_eq),
+    __ne__ = gateway.interp2app(W_BaseSetObject.descr_ne),
+    __lt__ = gateway.interp2app(W_BaseSetObject.descr_lt),
+    __le__ = gateway.interp2app(W_BaseSetObject.descr_le),
+    __gt__ = gateway.interp2app(W_BaseSetObject.descr_gt),
+    __ge__ = gateway.interp2app(W_BaseSetObject.descr_ge),
+
+    # non-mutating operators
+    __len__ = gateway.interp2app(W_BaseSetObject.descr_len),
+    __iter__ = gateway.interp2app(W_BaseSetObject.descr_iter),
+    __contains__ = gateway.interp2app(W_BaseSetObject.descr_contains),
+    __sub__ = gateway.interp2app(W_BaseSetObject.descr_sub),
+    __and__ = gateway.interp2app(W_BaseSetObject.descr_and),
+    __or__ = gateway.interp2app(W_BaseSetObject.descr_or),
+    __xor__ = gateway.interp2app(W_BaseSetObject.descr_xor),
+
+    # mutating operators
+    __isub__ = gateway.interp2app(W_BaseSetObject.descr_inplace_sub),
+    __iand__ = gateway.interp2app(W_BaseSetObject.descr_inplace_and),
+    __ior__ = gateway.interp2app(W_BaseSetObject.descr_inplace_or),
+    __ixor__ = gateway.interp2app(W_BaseSetObject.descr_inplace_xor),
+
+    # non-mutating methods
+    __reduce__ = gateway.interp2app(W_BaseSetObject.descr_reduce),
+    copy = gateway.interp2app(W_BaseSetObject.descr_copy),
+    difference = gateway.interp2app(W_BaseSetObject.descr_difference),
+    intersection = gateway.interp2app(W_BaseSetObject.descr_intersection),
+    issubset = gateway.interp2app(W_BaseSetObject.descr_issubset),
+    issuperset = gateway.interp2app(W_BaseSetObject.descr_issuperset),
+    symmetric_difference = gateway.interp2app(W_BaseSetObject.descr_symmetric_difference),
+    union = gateway.interp2app(W_BaseSetObject.descr_union),
+    isdisjoint = gateway.interp2app(W_BaseSetObject.descr_isdisjoint),
+
+    # mutating methods
+    add = gateway.interp2app(W_BaseSetObject.descr_add),
+    clear = gateway.interp2app(W_BaseSetObject.descr_clear),
+    difference_update = gateway.interp2app(W_BaseSetObject.descr_difference_update),
+    discard = gateway.interp2app(W_BaseSetObject.descr_discard),
+    intersection_update = gateway.interp2app(W_BaseSetObject.descr_intersection_update),
+    pop = gateway.interp2app(W_BaseSetObject.descr_pop),
+    remove = gateway.interp2app(W_BaseSetObject.descr_remove),
+    symmetric_difference_update = gateway.interp2app(W_BaseSetObject.descr_symmetric_difference_update),
+    update = gateway.interp2app(W_BaseSetObject.descr_update)
+    )
+set_typedef = W_SetObject.typedef
+
+
 class W_FrozensetObject(W_BaseSetObject):
-    from pypy.objspace.std.frozensettype import frozenset_typedef as typedef
     hash = 0
 
     def _newobj(w_self, space, w_iterable):
@@ -189,9 +586,77 @@
         W_FrozensetObject.__init__(w_obj, space, w_iterable)
         return w_obj
 
-registerimplementation(W_BaseSetObject)
-registerimplementation(W_SetObject)
-registerimplementation(W_FrozensetObject)
+    @staticmethod
+    def descr_new2(space, w_frozensettype, w_iterable=None):
+        if (space.is_w(w_frozensettype, space.w_frozenset) and
+            w_iterable is not None and type(w_iterable) is W_FrozensetObject):
+            return w_iterable
+        w_obj = space.allocate_instance(W_FrozensetObject, w_frozensettype)
+        W_FrozensetObject.__init__(w_obj, space, w_iterable)
+        return w_obj
+
+    def descr_hash(self, space):
+        multi = r_uint(1822399083) + r_uint(1822399083) + 1
+        if self.hash != 0:
+            return space.wrap(self.hash)
+        hash = r_uint(1927868237)
+        hash *= r_uint(self.length() + 1)
+        w_iterator = self.iter()
+        while True:
+            w_item = w_iterator.next_entry()
+            if w_item is None:
+                break
+            h = space.hash_w(w_item)
+            value = (r_uint(h ^ (h << 16) ^ 89869747)  * multi)
+            hash = hash ^ value
+        hash = hash * 69069 + 907133923
+        if hash == 0:
+            hash = 590923713
+        hash = intmask(hash)
+        self.hash = hash
+
+        return space.wrap(hash)
+
+W_FrozensetObject.typedef = StdTypeDef("frozenset",
+    __doc__ = """frozenset(iterable) --> frozenset object
+
+Build an immutable unordered collection.""",
+    __new__ = gateway.interp2app(W_FrozensetObject.descr_new2),
+    __repr__ = gateway.interp2app(W_BaseSetObject.descr_repr),
+    __hash__ = gateway.interp2app(W_FrozensetObject.descr_hash),
+    __cmp__ = gateway.interp2app(W_BaseSetObject.descr_cmp),
+
+    # comparison operators
+    __eq__ = gateway.interp2app(W_BaseSetObject.descr_eq),
+    __ne__ = gateway.interp2app(W_BaseSetObject.descr_ne),
+    __lt__ = gateway.interp2app(W_BaseSetObject.descr_lt),
+    __le__ = gateway.interp2app(W_BaseSetObject.descr_le),
+    __gt__ = gateway.interp2app(W_BaseSetObject.descr_gt),
+    __ge__ = gateway.interp2app(W_BaseSetObject.descr_ge),
+
+    # non-mutating operators
+    __len__ = gateway.interp2app(W_BaseSetObject.descr_len),
+    __iter__ = gateway.interp2app(W_BaseSetObject.descr_iter),
+    __contains__ = gateway.interp2app(W_BaseSetObject.descr_contains),
+    __sub__ = gateway.interp2app(W_BaseSetObject.descr_sub),
+    __and__ = gateway.interp2app(W_BaseSetObject.descr_and),
+    __or__ = gateway.interp2app(W_BaseSetObject.descr_or),
+    __xor__ = gateway.interp2app(W_BaseSetObject.descr_xor),
+
+    # non-mutating methods
+    __reduce__ = gateway.interp2app(W_BaseSetObject.descr_reduce),
+    copy = gateway.interp2app(W_BaseSetObject.descr_copy),
+    difference = gateway.interp2app(W_BaseSetObject.descr_difference),
+    intersection = gateway.interp2app(W_BaseSetObject.descr_intersection),
+    issubset = gateway.interp2app(W_BaseSetObject.descr_issubset),
+    issuperset = gateway.interp2app(W_BaseSetObject.descr_issuperset),
+    symmetric_difference = gateway.interp2app(W_BaseSetObject.descr_symmetric_difference),
+    union = gateway.interp2app(W_BaseSetObject.descr_union),
+    isdisjoint = gateway.interp2app(W_BaseSetObject.descr_isdisjoint)
+    )
+frozenset_typedef = W_FrozensetObject.typedef
+
+
 
 class SetStrategy(object):
     def __init__(self, space):
@@ -285,8 +750,8 @@
     def popitem(self, w_set):
         raise NotImplementedError
 
+
 class EmptySetStrategy(SetStrategy):
-
     erase, unerase = rerased.new_erasing_pair("empty")
     erase = staticmethod(erase)
     unerase = staticmethod(unerase)
@@ -377,6 +842,7 @@
         raise OperationError(self.space.w_KeyError,
                                 self.space.wrap('pop from an empty set'))
 
+
 class AbstractUnwrappedSetStrategy(object):
     _mixin_ = True
 
@@ -432,7 +898,6 @@
             w_set.add(w_key)
 
     def remove(self, w_set, w_item):
-        from pypy.objspace.std.dictmultiobject import _never_equal_to_string
         d = self.unerase(w_set.sstorage)
         if not self.is_correct_type(w_item):
             #XXX check type of w_item and immediately return False in some cases
@@ -464,7 +929,6 @@
         return keys_w
 
     def has_key(self, w_set, w_key):
-        from pypy.objspace.std.dictmultiobject import _never_equal_to_string
         if not self.is_correct_type(w_key):
             #XXX check type of w_item and immediately return False in some cases
             w_set.switch_to_object_strategy(self.space)
@@ -718,6 +1182,7 @@
                             self.space.wrap('pop from an empty set'))
         return self.wrap(result[0])
 
+
 class StringSetStrategy(AbstractUnwrappedSetStrategy, SetStrategy):
     erase, unerase = rerased.new_erasing_pair("string")
     erase = staticmethod(erase)
@@ -801,7 +1266,6 @@
         return self.unerase(w_set.sstorage).keys()
 
     def is_correct_type(self, w_key):
-        from pypy.objspace.std.intobject import W_IntObject
         return type(w_key) is W_IntObject
 
     def may_contain_equal_elements(self, strategy):
@@ -822,6 +1286,7 @@
     def iter(self, w_set):
         return IntegerIteratorImplementation(self.space, self, w_set)
 
+
 class ObjectSetStrategy(AbstractUnwrappedSetStrategy, SetStrategy):
     erase, unerase = rerased.new_erasing_pair("object")
     erase = staticmethod(erase)
@@ -866,6 +1331,7 @@
                 break
             d_obj[w_item] = None
 
+
 class IteratorImplementation(object):
     def __init__(self, space, strategy, implementation):
         self.space = space
@@ -910,6 +1376,7 @@
             return self.len - self.pos
         return 0
 
+
 class EmptyIteratorImplementation(IteratorImplementation):
     def next_entry(self):
         return None
@@ -927,6 +1394,7 @@
         else:
             return None
 
+
 class UnicodeIteratorImplementation(IteratorImplementation):
     def __init__(self, space, strategy, w_set):
         IteratorImplementation.__init__(self, space, strategy, w_set)
@@ -939,6 +1407,7 @@
         else:
             return None
 
+
 class IntegerIteratorImplementation(IteratorImplementation):
     #XXX same implementation in dictmultiobject on dictstrategy-branch
     def __init__(self, space, strategy, w_set):
@@ -953,6 +1422,7 @@
         else:
             return None
 
+
 class RDictIteratorImplementation(IteratorImplementation):
     def __init__(self, space, strategy, w_set):
         IteratorImplementation.__init__(self, space, strategy, w_set)
@@ -966,26 +1436,34 @@
         else:
             return None
 
-class W_SetIterObject(W_Object):
-    from pypy.objspace.std.settype import setiter_typedef as typedef
-    # XXX this class should be killed, and the various
-    # iterimplementations should be W_Objects directly.
+
+class W_SetIterObject(W_Root):
 
     def __init__(w_self, space, iterimplementation):
         w_self.space = space
         w_self.iterimplementation = iterimplementation
 
-registerimplementation(W_SetIterObject)
+    def descr_length_hint(self, space):
+        return space.wrap(self.iterimplementation.length())
 
-def iter__SetIterObject(space, w_setiter):
-    return w_setiter
+    def descr_iter(self, space):
+        return self
 
-def next__SetIterObject(space, w_setiter):
-    iterimplementation = w_setiter.iterimplementation
-    w_key = iterimplementation.next()
-    if w_key is not None:
-        return w_key
-    raise OperationError(space.w_StopIteration, space.w_None)
+    def descr_next(self, space):
+        iterimplementation = self.iterimplementation
+        w_key = iterimplementation.next()
+        if w_key is not None:
+            return w_key
+        raise OperationError(space.w_StopIteration, space.w_None)
+
+W_SetIterObject.typedef = StdTypeDef("setiterator",
+    __length_hint__ = gateway.interp2app(W_SetIterObject.descr_length_hint),
+    __iter__ = gateway.interp2app(W_SetIterObject.descr_iter),
+    next = gateway.interp2app(W_SetIterObject.descr_next)
+    )
+setiter_typedef = W_SetIterObject.typedef
+
+
 
 # some helper functions
 
@@ -993,7 +1471,6 @@
     return r_dict(space.eq_w, space.hash_w, force_non_null=True)
 
 def set_strategy_and_setdata(space, w_set, w_iterable):
-    from pypy.objspace.std.intobject import W_IntObject
     if w_iterable is None :
         w_set.strategy = strategy = space.fromcache(EmptySetStrategy)
         w_set.sstorage = strategy.get_empty_storage()
@@ -1067,6 +1544,8 @@
     w_set.strategy = space.fromcache(ObjectSetStrategy)
     w_set.sstorage = w_set.strategy.get_storage_from_list(iterable_w)
 
+init_signature = Signature(['some_iterable'], None, None)
+init_defaults = [None]
 def _initialize_set(space, w_obj, w_iterable=None):
     w_obj.clear()
     set_strategy_and_setdata(space, w_obj, w_iterable)
@@ -1084,424 +1563,6 @@
     else:
         return None
 
-def set_update__Set(space, w_left, others_w):
-    """Update a set with the union of itself and another."""
-    for w_other in others_w:
-        if isinstance(w_other, W_BaseSetObject):
-            w_left.update(w_other)     # optimization only
-        else:
-            for w_key in space.listview(w_other):
-                w_left.add(w_key)
-
-def inplace_or__Set_Set(space, w_left, w_other):
-    w_left.update(w_other)
-    return w_left
-
-inplace_or__Set_Frozenset = inplace_or__Set_Set
-
-def set_add__Set_ANY(space, w_left, w_other):
-    """Add an element to a set.
-
-    This has no effect if the element is already present.
-    """
-    w_left.add(w_other)
-
-def set_copy__Set(space, w_set):
-    return w_set.copy_real()
-
-def frozenset_copy__Frozenset(space, w_left):
-    if type(w_left) is W_FrozensetObject:
-        return w_left
-    else:
-        return set_copy__Set(space, w_left)
-
-def set_clear__Set(space, w_left):
-    w_left.clear()
-
-def sub__Set_Set(space, w_left, w_other):
-    return w_left.difference(w_other)
-
-sub__Set_Frozenset = sub__Set_Set
-sub__Frozenset_Set = sub__Set_Set
-sub__Frozenset_Frozenset = sub__Set_Set
-
-def set_difference__Set(space, w_left, others_w):
-    result = w_left.copy_real()
-    set_difference_update__Set(space, result, others_w)
-    return result
-
-frozenset_difference__Frozenset = set_difference__Set
-
-
-def set_difference_update__Set(space, w_left, others_w):
-    for w_other in others_w:
-        if isinstance(w_other, W_BaseSetObject):
-            # optimization only
-            w_left.difference_update(w_other)
-        else:
-            w_other_as_set = w_left._newobj(space, w_other)
-            w_left.difference_update(w_other_as_set)
-
-def inplace_sub__Set_Set(space, w_left, w_other):
-    w_left.difference_update(w_other)
-    return w_left
-
-inplace_sub__Set_Frozenset = inplace_sub__Set_Set
-
-def eq__Set_Set(space, w_left, w_other):
-    # optimization only (the general case is eq__Set_settypedef)
-    return space.wrap(w_left.equals(w_other))
-
-eq__Set_Frozenset = eq__Set_Set
-eq__Frozenset_Frozenset = eq__Set_Set
-eq__Frozenset_Set = eq__Set_Set
-
-def eq__Set_settypedef(space, w_left, w_other):
-    # tested in test_buildinshortcut.py
-    #XXX do not make new setobject here
-    w_other_as_set = w_left._newobj(space, w_other)
-    return space.wrap(w_left.equals(w_other_as_set))
-
-eq__Set_frozensettypedef = eq__Set_settypedef
-eq__Frozenset_settypedef = eq__Set_settypedef
-eq__Frozenset_frozensettypedef = eq__Set_settypedef
-
-def eq__Set_ANY(space, w_left, w_other):
-    # workaround to have "set() == 42" return False instead of falling
-    # back to cmp(set(), 42) because the latter raises a TypeError
-    return space.w_False
-
-eq__Frozenset_ANY = eq__Set_ANY
-
-def ne__Set_Set(space, w_left, w_other):
-    return space.wrap(not w_left.equals(w_other))
-
-ne__Set_Frozenset = ne__Set_Set
-ne__Frozenset_Frozenset = ne__Set_Set
-ne__Frozenset_Set = ne__Set_Set
-
-def ne__Set_settypedef(space, w_left, w_other):
-    #XXX this is not tested
-    w_other_as_set = w_left._newobj(space, w_other)
-    return space.wrap(not w_left.equals(w_other_as_set))
-
-ne__Set_frozensettypedef = ne__Set_settypedef
-ne__Frozenset_settypedef = ne__Set_settypedef
-ne__Frozenset_frozensettypedef = ne__Set_settypedef
-
-
-def ne__Set_ANY(space, w_left, w_other):
-    # more workarounds
-    return space.w_True
-
-ne__Frozenset_ANY = ne__Set_ANY
-
-def contains__Set_ANY(space, w_left, w_other):
-    try:
-        return space.newbool(w_left.has_key(w_other))
-    except OperationError, e:
-        if e.match(space, space.w_TypeError):
-            w_f = _convert_set_to_frozenset(space, w_other)
-            if w_f is not None:
-                return space.newbool(w_left.has_key(w_f))
-        raise
-
-contains__Frozenset_ANY = contains__Set_ANY
-
-def set_issubset__Set_Set(space, w_left, w_other):
-    # optimization only (the general case works too)
-    if space.is_w(w_left, w_other):
-        return space.w_True
-    if w_left.length() > w_other.length():
-        return space.w_False
-    return space.wrap(w_left.issubset(w_other))
-
-set_issubset__Set_Frozenset = set_issubset__Set_Set
-frozenset_issubset__Frozenset_Set = set_issubset__Set_Set
-frozenset_issubset__Frozenset_Frozenset = set_issubset__Set_Set
-
-def set_issubset__Set_ANY(space, w_left, w_other):
-    # not checking whether w_left is w_other here, because if that were the
-    # case the more precise multimethod would have applied.
-
-    w_other_as_set = w_left._newobj(space, w_other)
-
-    if w_left.length() > w_other_as_set.length():
-        return space.w_False
-    return space.wrap(w_left.issubset(w_other_as_set))
-
-frozenset_issubset__Frozenset_ANY = set_issubset__Set_ANY
-
-le__Set_Set = set_issubset__Set_Set
-le__Set_Frozenset = set_issubset__Set_Set
-le__Frozenset_Set = set_issubset__Set_Set
-le__Frozenset_Frozenset = set_issubset__Set_Set
-
-def set_issuperset__Set_Set(space, w_left, w_other):
-    # optimization only (the general case works too)
-    if space.is_w(w_left, w_other):
-        return space.w_True
-    if w_left.length() < w_other.length():
-        return space.w_False
-    return space.wrap(w_other.issubset(w_left))
-
-set_issuperset__Set_Frozenset = set_issuperset__Set_Set
-set_issuperset__Frozenset_Set = set_issuperset__Set_Set
-set_issuperset__Frozenset_Frozenset = set_issuperset__Set_Set
-
-def set_issuperset__Set_ANY(space, w_left, w_other):
-    if space.is_w(w_left, w_other):
-        return space.w_True
-
-    w_other_as_set = w_left._newobj(space, w_other)
-
-    if w_left.length() < w_other_as_set.length():
-        return space.w_False
-    return space.wrap(w_other_as_set.issubset(w_left))
-
-frozenset_issuperset__Frozenset_ANY = set_issuperset__Set_ANY
-
-ge__Set_Set = set_issuperset__Set_Set
-ge__Set_Frozenset = set_issuperset__Set_Set
-ge__Frozenset_Set = set_issuperset__Set_Set
-ge__Frozenset_Frozenset = set_issuperset__Set_Set
-
-# automatic registration of "lt(x, y)" as "not ge(y, x)" would not give the
-# correct answer here!
-def lt__Set_Set(space, w_left, w_other):
-    if w_left.length() >= w_other.length():
-        return space.w_False
-    else:
-        return le__Set_Set(space, w_left, w_other)
-
-lt__Set_Frozenset = lt__Set_Set
-lt__Frozenset_Set = lt__Set_Set
-lt__Frozenset_Frozenset = lt__Set_Set
-
-def gt__Set_Set(space, w_left, w_other):
-    if w_left.length() <= w_other.length():
-        return space.w_False
-    else:
-        return ge__Set_Set(space, w_left, w_other)
-
-gt__Set_Frozenset = gt__Set_Set
-gt__Frozenset_Set = gt__Set_Set
-gt__Frozenset_Frozenset = gt__Set_Set
-
-def _discard_from_set(space, w_left, w_item):
-    """
-    Discard an element from a set, with automatic conversion to
-    frozenset if the argument is a set.
-    Returns True if successfully removed.
-    """
-    try:
-        deleted = w_left.remove(w_item)
-    except OperationError, e:
-        if not e.match(space, space.w_TypeError):
-            raise
-        else:
-            w_f = _convert_set_to_frozenset(space, w_item)
-            if w_f is None:
-                raise
-            deleted = w_left.remove(w_f)
-
-    if w_left.length() == 0:
-        w_left.switch_to_empty_strategy()
-    return deleted
-
-def set_discard__Set_ANY(space, w_left, w_item):
-    _discard_from_set(space, w_left, w_item)
-
-def set_remove__Set_ANY(space, w_left, w_item):
-    if not _discard_from_set(space, w_left, w_item):
-        space.raise_key_error(w_item)
-
-def hash__Frozenset(space, w_set):
-    multi = r_uint(1822399083) + r_uint(1822399083) + 1
-    if w_set.hash != 0:
-        return space.wrap(w_set.hash)
-    hash = r_uint(1927868237)
-    hash *= r_uint(w_set.length() + 1)
-    w_iterator = w_set.iter()
-    while True:
-        w_item = w_iterator.next_entry()
-        if w_item is None:
-            break
-        h = space.hash_w(w_item)
-        value = (r_uint(h ^ (h << 16) ^ 89869747)  * multi)
-        hash = hash ^ value
-    hash = hash * 69069 + 907133923
-    if hash == 0:
-        hash = 590923713
-    hash = intmask(hash)
-    w_set.hash = hash
-
-    return space.wrap(hash)
-
-def set_pop__Set(space, w_left):
-    return w_left.popitem()
-
-def and__Set_Set(space, w_left, w_other):
-    new_set = w_left.intersect(w_other)
-    return new_set
-
-and__Set_Frozenset = and__Set_Set
-and__Frozenset_Set = and__Set_Set
-and__Frozenset_Frozenset = and__Set_Set
-
-def set_intersection__Set(space, w_left, others_w):
-    #XXX find smarter implementations
-    others_w = [w_left] + others_w
-
-    # find smallest set in others_w to reduce comparisons
-    startindex, startlength = 0, -1
-    for i in range(len(others_w)):
-        w_other = others_w[i]
-        try:
-            length = space.int_w(space.len(w_other))
-        except OperationError, e:
-            if (e.match(space, space.w_TypeError) or
-                e.match(space, space.w_AttributeError)):
-                continue
-            raise
-
-        if startlength == -1 or length < startlength:
-            startindex = i
-            startlength = length
-
-    others_w[startindex], others_w[0] = others_w[0], others_w[startindex]
-
-    result = w_left._newobj(space, others_w[0])
-    for i in range(1,len(others_w)):
-        w_other = others_w[i]
-        if isinstance(w_other, W_BaseSetObject):
-            # optimization only
-            result.intersect_update(w_other)
-        else:
-            w_other_as_set = w_left._newobj(space, w_other)
-            result.intersect_update(w_other_as_set)
-    return result
-
-frozenset_intersection__Frozenset = set_intersection__Set
-
-def set_intersection_update__Set(space, w_left, others_w):
-    result = set_intersection__Set(space, w_left, others_w)
-    w_left.strategy = result.strategy
-    w_left.sstorage = result.sstorage
-    return
-
-def inplace_and__Set_Set(space, w_left, w_other):
-    w_left.intersect_update(w_other)
-    return w_left
-
-inplace_and__Set_Frozenset = inplace_and__Set_Set
-
-def set_isdisjoint__Set_Set(space, w_left, w_other):
-    # optimization only (the general case works too)
-    return space.newbool(w_left.isdisjoint(w_other))
-
-set_isdisjoint__Set_Frozenset = set_isdisjoint__Set_Set
-set_isdisjoint__Frozenset_Frozenset = set_isdisjoint__Set_Set
-set_isdisjoint__Frozenset_Set = set_isdisjoint__Set_Set
-
-def set_isdisjoint__Set_ANY(space, w_left, w_other):
-    #XXX may be optimized when other strategies are added
-    for w_key in space.listview(w_other):
-        if w_left.has_key(w_key):
-            return space.w_False
-    return space.w_True
-
-frozenset_isdisjoint__Frozenset_ANY = set_isdisjoint__Set_ANY
-
-def set_symmetric_difference__Set_Set(space, w_left, w_other):
-    # optimization only (the general case works too)
-    w_result = w_left.symmetric_difference(w_other)
-    return w_result
-
-set_symmetric_difference__Set_Frozenset = set_symmetric_difference__Set_Set
-set_symmetric_difference__Frozenset_Set = set_symmetric_difference__Set_Set
-set_symmetric_difference__Frozenset_Frozenset = \
-                                        set_symmetric_difference__Set_Set
-
-xor__Set_Set = set_symmetric_difference__Set_Set
-xor__Set_Frozenset = set_symmetric_difference__Set_Set
-xor__Frozenset_Set = set_symmetric_difference__Set_Set
-xor__Frozenset_Frozenset = set_symmetric_difference__Set_Set
-
-
-def set_symmetric_difference__Set_ANY(space, w_left, w_other):
-    w_other_as_set = w_left._newobj(space, w_other)
-    w_result = w_left.symmetric_difference(w_other_as_set)
-    return w_result
-
-frozenset_symmetric_difference__Frozenset_ANY = \
-        set_symmetric_difference__Set_ANY
-
-def set_symmetric_difference_update__Set_Set(space, w_left, w_other):
-    # optimization only (the general case works too)
-    w_left.symmetric_difference_update(w_other)
-
-set_symmetric_difference_update__Set_Frozenset = \
-                                    set_symmetric_difference_update__Set_Set
-
-def set_symmetric_difference_update__Set_ANY(space, w_left, w_other):
-    w_other_as_set = w_left._newobj(space, w_other)
-    w_left.symmetric_difference_update(w_other_as_set)
-
-def inplace_xor__Set_Set(space, w_left, w_other):
-    set_symmetric_difference_update__Set_Set(space, w_left, w_other)
-    return w_left
-
-inplace_xor__Set_Frozenset = inplace_xor__Set_Set
-
-def or__Set_Set(space, w_left, w_other):
-    w_copy = w_left.copy_real()
-    w_copy.update(w_other)
-    return w_copy
-
-or__Set_Frozenset = or__Set_Set
-or__Frozenset_Set = or__Set_Set
-or__Frozenset_Frozenset = or__Set_Set
-
-def set_union__Set(space, w_left, others_w):
-    result = w_left.copy_real()
-    for w_other in others_w:
-        if isinstance(w_other, W_BaseSetObject):
-            result.update(w_other)     # optimization only
-        else:
-            for w_key in space.listview(w_other):
-                result.add(w_key)
-    return result
-
-frozenset_union__Frozenset = set_union__Set
-
-def len__Set(space, w_left):
-    return space.newint(w_left.length())
-
-len__Frozenset = len__Set
-
-def iter__Set(space, w_left):
-    return W_SetIterObject(space, w_left.iter())
-
-iter__Frozenset = iter__Set
-
-def cmp__Set_settypedef(space, w_left, w_other):
-    # hack hack until we get the expected result
-    raise OperationError(space.w_TypeError,
-            space.wrap('cannot compare sets using cmp()'))
-
-cmp__Set_frozensettypedef = cmp__Set_settypedef
-cmp__Frozenset_settypedef = cmp__Set_settypedef
-cmp__Frozenset_frozensettypedef = cmp__Set_settypedef
-
-init_signature = Signature(['some_iterable'], None, None)
-init_defaults = [None]
-def init__Set(space, w_set, __args__):
-    w_iterable, = __args__.parse_obj(
-            None, 'set',
-            init_signature,
-            init_defaults)
-    _initialize_set(space, w_set, w_iterable)
 
 app = gateway.applevel("""
     def setrepr(currently_in_repr, s):
@@ -1521,26 +1582,11 @@
 
 setrepr = app.interphook("setrepr")
 
-def repr__Set(space, w_set):
-    ec = space.getexecutioncontext()
-    w_currently_in_repr = ec._py_repr
-    if w_currently_in_repr is None:
-        w_currently_in_repr = ec._py_repr = space.newdict()
-    return setrepr(space, w_currently_in_repr, w_set)
-
-repr__Frozenset = repr__Set
-
 app = gateway.applevel("""
-    def reduce__Set(s):
+    def setreduce(s):
         dict = getattr(s,'__dict__', None)
         return (s.__class__, (tuple(s),), dict)
 
 """, filename=__file__)
 
-set_reduce__Set = app.interphook('reduce__Set')
-frozenset_reduce__Frozenset = app.interphook('reduce__Set')
-
-from pypy.objspace.std import frozensettype
-from pypy.objspace.std import settype
-
-register_all(vars(), settype, frozensettype)
+setreduce = app.interphook('setreduce')
diff --git a/pypy/objspace/std/settype.py b/pypy/objspace/std/settype.py
deleted file mode 100644
--- a/pypy/objspace/std/settype.py
+++ /dev/null
@@ -1,91 +0,0 @@
-from pypy.interpreter.error import OperationError
-from pypy.interpreter import gateway
-from pypy.objspace.std.register_all import register_all
-from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
-
-set_add                         = SMM('add', 2,
-                                      doc='Add an element to a set.\n\nThis'
-                                          ' has no effect if the element is'
-                                          ' already present.')
-set_clear                       = SMM('clear', 1,
-                                      doc='Remove all elements from this set.')
-set_copy                        = SMM('copy', 1,
-                                      doc='Return a shallow copy of a set.')
-set_difference                  = SMM('difference', 1, varargs_w=True,
-                                      doc='Return a new set with elements in'
-                                          ' the set that are not in the others.')
-set_difference_update           = SMM('difference_update', 1, varargs_w=True,
-                                      doc='Update the set, removing elements'
-                                          ' found in others.')
-set_discard                     = SMM('discard', 2,
-                                      doc='Remove an element from a set if it'
-                                          ' is a member.\n\nIf the element is'
-                                          ' not a member, do nothing.')
-set_intersection                = SMM('intersection', 1, varargs_w=True,
-                                      doc='Return a new set with elements common'
-                                          ' to the set and all others.')
-set_intersection_update         = SMM('intersection_update', 1, varargs_w=True,
-                                      doc='Update the set, keeping only elements'
-                                          ' found in it and all others.')
-set_issubset                    = SMM('issubset', 2,
-                                      doc='Report whether another set contains'
-                                          ' this set.')
-set_issuperset                  = SMM('issuperset', 2,
-                                      doc='Report whether this set contains'
-                                          ' another set.')
-set_pop                         = SMM('pop', 1,
-                                      doc='Remove and return an arbitrary set'
-                                          ' element.')
-set_remove                      = SMM('remove', 2,
-                                      doc='Remove an element from a set; it'
-                                          ' must be a member.\n\nIf the'
-                                          ' element is not a member, raise a'
-                                          ' KeyError.')
-set_symmetric_difference        = SMM('symmetric_difference', 2,
-                                      doc='Return the symmetric difference of'
-                                          ' two sets as a new set.\n\n(i.e.'
-                                          ' all elements that are in exactly'
-                                          ' one of the sets.)')
-set_symmetric_difference_update = SMM('symmetric_difference_update', 2,
-                                      doc='Update a set with the symmetric'
-                                          ' difference of itself and another.')
-set_union                       = SMM('union', 1, varargs_w=True,
-                                      doc='Return a new set with elements'
-                                          ' from the set and all others.')
-set_update                      = SMM('update', 1, varargs_w=True,
-                                      doc='Update the set, adding elements'
-                                          ' from all others.')
-set_reduce                      = SMM('__reduce__',1,
-                                      doc='Return state information for'
-                                          ' pickling.')
-# 2.6 methods
-set_isdisjoint                  = SMM('isdisjoint', 2,
-                                      doc='Return True if two sets have a'
-                                          ' null intersection.')
-
-register_all(vars(), globals())
-
-def descr__new__(space, w_settype, __args__):
-    from pypy.objspace.std.setobject import W_SetObject, newset
-    w_obj = space.allocate_instance(W_SetObject, w_settype)
-    W_SetObject.__init__(w_obj, space)
-    return w_obj
-
-set_typedef = StdTypeDef("set",
-    __doc__ = """set(iterable) --> set object
-
-Build an unordered collection.""",
-    __new__ = gateway.interp2app(descr__new__),
-    __hash__ = None,
-    )
-
-set_typedef.registermethods(globals())
-
-def descr_setiterator__length_hint__(space, w_self):
-    from pypy.objspace.std.setobject import W_SetIterObject
-    assert isinstance(w_self, W_SetIterObject)
-    return space.wrap(w_self.iterimplementation.length())
-
-setiter_typedef = StdTypeDef("setiterator",
-    __length_hint__ = gateway.interp2app(descr_setiterator__length_hint__),
-    )
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
@@ -12,9 +12,6 @@
 from pypy.objspace.std.setobject import W_SetObject, W_FrozensetObject, IntegerSetStrategy
 from pypy.objspace.std.setobject import _initialize_set
 from pypy.objspace.std.setobject import newset
-from pypy.objspace.std.setobject import and__Set_Set
-from pypy.objspace.std.setobject import set_intersection__Set
-from pypy.objspace.std.setobject import eq__Set_Set
 from pypy.objspace.std.listobject import W_ListObject
 
 letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
@@ -36,11 +33,11 @@
         t0 = W_SetObject(self.space)
         _initialize_set(self.space, t0, self.otherword)
         t1 = W_FrozensetObject(self.space, self.otherword)
-        r0 = and__Set_Set(self.space, s, t0)
-        r1 = and__Set_Set(self.space, s, t1)
-        assert eq__Set_Set(self.space, r0, r1) == self.true
-        sr = set_intersection__Set(self.space, s, [self.otherword])
-        assert eq__Set_Set(self.space, r0, sr) == self.true
+        r0 = s.descr_and(self.space, t0)
+        r1 = s.descr_and(self.space, t1)
+        assert r0.descr_eq(self.space, r1) == self.true
+        sr = s.descr_intersection(self.space, [self.otherword])
+        assert r0.descr_eq(self.space, sr) == self.true
 
     def test_compare(self):
         s = W_SetObject(self.space)
@@ -66,7 +63,7 @@
         b = W_SetObject(self.space)
         _initialize_set(self.space, b, self.space.wrap("abc"))
 
-        result = set_intersection__Set(space, a, [b])
+        result = a.descr_intersection(space, [b])
         assert space.is_true(self.space.eq(result, W_SetObject(space, self.space.wrap("abc"))))
 
         c = W_SetObject(self.space)
@@ -80,7 +77,7 @@
         b.get_storage_copy = None
         d.get_storage_copy = None
 
-        result = set_intersection__Set(space, a, [d,c,b])
+        result = a.descr_intersection(space, [d,c,b])
         assert space.is_true(self.space.eq(result, W_SetObject(space, self.space.wrap(""))))
 
     def test_create_set_from_list(self):
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
@@ -65,18 +65,16 @@
         assert s1.strategy is self.space.fromcache(EmptySetStrategy)
 
     def test_remove(self):
-        from pypy.objspace.std.setobject import set_remove__Set_ANY
         s1 = W_SetObject(self.space, self.wrapped([1]))
-        set_remove__Set_ANY(self.space, s1, self.space.wrap(1))
+        self.space.call_method(s1, 'remove', self.space.wrap(1))
         assert s1.strategy is self.space.fromcache(EmptySetStrategy)
 
     def test_union(self):
-        from pypy.objspace.std.setobject import set_union__Set
         s1 = W_SetObject(self.space, self.wrapped([1,2,3,4,5]))
         s2 = W_SetObject(self.space, self.wrapped([4,5,6,7]))
         s3 = W_SetObject(self.space, self.wrapped([4,'5','6',7]))
-        s4 = set_union__Set(self.space, s1, [s2])
-        s5 = set_union__Set(self.space, s1, [s3])
+        s4 = s1.descr_union(self.space, [s2])
+        s5 = s1.descr_union(self.space, [s3])
         assert s4.strategy is self.space.fromcache(IntegerSetStrategy)
         assert s5.strategy is self.space.fromcache(ObjectSetStrategy)
 
@@ -91,10 +89,8 @@
                     return True
                 return False
 
-        from pypy.objspace.std.setobject import set_discard__Set_ANY
-
         s1 = W_SetObject(self.space, self.wrapped([1,2,3,4,5]))
-        set_discard__Set_ANY(self.space, s1, self.space.wrap("five"))
+        s1.descr_discard(self.space, self.space.wrap("five"))
         skip("currently not supported")
         assert s1.strategy is self.space.fromcache(IntegerSetStrategy)
 
@@ -112,8 +108,6 @@
                     return True
                 return False
 
-        from pypy.objspace.std.setobject import set_discard__Set_ANY
-
         s1 = W_SetObject(self.space, self.wrapped([1,2,3,4,5]))
         assert not s1.has_key(self.space.wrap("five"))
         skip("currently not supported")
diff --git a/rpython/jit/metainterp/test/test_compile.py b/rpython/jit/metainterp/test/test_compile.py
--- a/rpython/jit/metainterp/test/test_compile.py
+++ b/rpython/jit/metainterp/test/test_compile.py
@@ -1,10 +1,10 @@
 from rpython.config.translationoption import get_combined_translation_config
-from rpython.jit.metainterp.history import TargetToken, ConstInt, History, Stats
-from rpython.jit.metainterp.history import BoxInt, INT
+from rpython.jit.metainterp.history import ConstInt, History, Stats
+from rpython.jit.metainterp.history import INT
 from rpython.jit.metainterp.compile import compile_loop
-from rpython.jit.metainterp.compile import ResumeGuardDescr
 from rpython.jit.metainterp.compile import ResumeGuardCountersInt
 from rpython.jit.metainterp.compile import compile_tmp_callback
+from rpython.jit.metainterp import jitexc
 from rpython.jit.metainterp import jitprof, typesystem, compile
 from rpython.jit.metainterp.optimizeopt.test.test_util import LLtypeMixin
 from rpython.jit.tool.oparser import parse
@@ -13,7 +13,7 @@
 class FakeCPU(object):
     class tracker:
         pass
-    
+
     ts = typesystem.llhelper
     def __init__(self):
         self.seen = []
@@ -41,7 +41,7 @@


More information about the pypy-commit mailing list