[pypy-commit] pypy kill-multimethod: Move issubtypedef into typeobject.py.

Manuel Jacob noreply at buildbot.pypy.org
Tue Feb 25 19:22:42 CET 2014


Author: Manuel Jacob
Branch: kill-multimethod
Changeset: r69442:cb191419517d
Date: 2014-02-25 18:56 +0100
http://bitbucket.org/pypy/pypy/changeset/cb191419517d/

Log:	Move issubtypedef into typeobject.py.

diff --git a/pypy/objspace/std/stdtypedef.py b/pypy/objspace/std/stdtypedef.py
--- a/pypy/objspace/std/stdtypedef.py
+++ b/pypy/objspace/std/stdtypedef.py
@@ -1,9 +1,7 @@
-from pypy.interpreter import baseobjspace
 from pypy.interpreter.typedef import TypeDef, GetSetProperty, Member
 from pypy.interpreter.typedef import descr_get_dict, descr_set_dict
 from pypy.interpreter.typedef import descr_del_dict
 from pypy.interpreter.baseobjspace import SpaceCache
-from rpython.rlib import jit
 
 __all__ = ['StdTypeDef']
 
@@ -11,29 +9,10 @@
 StdTypeDef = TypeDef
 
 
- at jit.unroll_safe
-def issubtypedef(a, b):
-    from pypy.objspace.std.objectobject import W_ObjectObject
-    if b is W_ObjectObject.typedef:
-        return True
-    if a is None:
-        return False
-    if a is b:
-        return True
-    for a1 in a.bases:
-        if issubtypedef(a1, b):
-            return True
-    return False
-
 std_dict_descr = GetSetProperty(descr_get_dict, descr_set_dict, descr_del_dict,
                     doc="dictionary for instance variables (if defined)")
 std_dict_descr.name = '__dict__'
 
-# ____________________________________________________________
-#
-# All the code below fishes from the multimethod registration tables
-# the descriptors to put into the W_TypeObjects.
-#
 
 class TypeCache(SpaceCache):
     def build(cache, typedef):
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -5,7 +5,7 @@
 from pypy.interpreter.typedef import weakref_descr, GetSetProperty,\
      descr_get_dict
 from pypy.interpreter.astcompiler.misc import mangle
-from pypy.objspace.std.stdtypedef import std_dict_descr, issubtypedef, Member
+from pypy.objspace.std.stdtypedef import std_dict_descr, Member
 from pypy.objspace.std.stdtypedef import StdTypeDef
 
 from rpython.rlib.jit import (promote, elidable_promote, we_are_jitted,
@@ -907,6 +907,20 @@
         w_layout1 = w_layout1.w_same_layout_as or w_layout1
     return True
 
+ at unroll_safe
+def issubtypedef(a, b):
+    from pypy.objspace.std.objectobject import W_ObjectObject
+    if b is W_ObjectObject.typedef:
+        return True
+    if a is None:
+        return False
+    if a is b:
+        return True
+    for a1 in a.bases:
+        if issubtypedef(a1, b):
+            return True
+    return False
+
 def find_best_base(space, bases_w):
     """The best base is one of the bases in the given list: the one
        whose layout a new type should use as a starting point.


More information about the pypy-commit mailing list