[pypy-commit] pypy default: Let the JIT see the app-level 'type(x)' construct.

arigo noreply at buildbot.pypy.org
Tue Dec 13 13:55:54 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r50462:7d73e99929bb
Date: 2011-12-13 13:55 +0100
http://bitbucket.org/pypy/pypy/changeset/7d73e99929bb/

Log:	Let the JIT see the app-level 'type(x)' construct.

diff --git a/pypy/objspace/std/typetype.py b/pypy/objspace/std/typetype.py
--- a/pypy/objspace/std/typetype.py
+++ b/pypy/objspace/std/typetype.py
@@ -10,7 +10,6 @@
     w_dict=gateway.NoneNotWrapped):
 
     "This is used to create user-defined classes only."
-    from pypy.objspace.std.typeobject import W_TypeObject
     # XXX check types
 
     w_typetype = _precheck_for_new(space, w_typetype)
@@ -19,10 +18,18 @@
     if (space.is_w(space.type(w_typetype), space.w_type) and w_bases is None and
         w_dict is None):
         return space.type(w_name)
-    elif w_bases is None or w_dict is None:
+    else:
+        return _create_new_type(space, w_typetype, w_name, w_bases, w_dict)
+
+
+def _create_new_type(space, w_typetype, w_name, w_bases, w_dict):
+    # this is in its own function because we want the special case 'type(x)'
+    # above to be seen by the jit.
+    from pypy.objspace.std.typeobject import W_TypeObject
+
+    if w_bases is None or w_dict is None:
         raise OperationError(space.w_TypeError, space.wrap("type() takes 1 or 3 arguments"))
 
-
     bases_w = space.fixedview(w_bases)
 
     w_winner = w_typetype


More information about the pypy-commit mailing list