[pypy-svn] r40161 - pypy/dist/pypy/interpreter

arigo at codespeak.net arigo at codespeak.net
Sat Mar 10 14:45:30 CET 2007


Author: arigo
Date: Sat Mar 10 14:45:29 2007
New Revision: 40161

Modified:
   pypy/dist/pypy/interpreter/callmethod.py
Log:
Revert this change for now.  It's still in the svn history, and
(little though I trust them) the measures say it makes things
slower.  Nonsense, but at least it's less code.


Modified: pypy/dist/pypy/interpreter/callmethod.py
==============================================================================
--- pypy/dist/pypy/interpreter/callmethod.py	(original)
+++ pypy/dist/pypy/interpreter/callmethod.py	Sat Mar 10 14:45:29 2007
@@ -11,8 +11,13 @@
 """
 
 from pypy.interpreter import pyframe, function
-from pypy.interpreter.error import OperationError
-from pypy.objspace.descroperation import DescrOperation, raiseattrerror
+
+
+def object_getattribute(space):
+    w_src, w_getattribute = space.lookup_in_type_where(space.w_object,
+                                                       '__getattribute__')
+    return w_getattribute
+object_getattribute._annspecialcase_ = 'specialize:memo'
 
 
 class __extend__(pyframe.PyFrame):
@@ -29,18 +34,16 @@
         space = f.space
         w_obj = f.popvalue()
         w_name = f.getname_w(nameindex)
-        if isinstance(space, DescrOperation):
-            w_getattribute = space.lookup(w_obj, '__getattribute__')
-            ok_to_optimize = w_getattribute is object_getattribute(space)
-        else:
-            ok_to_optimize = False
-
-        if not ok_to_optimize:
-            w_value = space.getattr(w_obj, w_name)
-        else:
+        w_value = None
+        w_getattribute = space.lookup(w_obj, '__getattribute__')
+        if w_getattribute is object_getattribute(space):
             name = space.str_w(w_name)
             w_descr = space.lookup(w_obj, name)
-            if type(w_descr) is function.Function:
+            if w_descr is None:
+                # this handles directly the common case
+                #   module.function(args..)
+                w_value = w_obj.getdictvalue(space, w_name)
+            elif type(w_descr) is function.Function:
                 w_value = w_obj.getdictvalue_attr_is_in_class(space, w_name)
                 if w_value is None:
                     # fast method path: a function object in the class,
@@ -48,13 +51,8 @@
                     f.pushvalue(w_descr)
                     f.pushvalue(w_obj)
                     return
-                # else we have a function object in the class, but shadowed
-                # by an instance attribute
-            else:
-                # anything else than a function object in the class
-                # => use the default lookup logic, without re-looking-up
-                #    w_descr and __getattribute__, though
-                w_value = default_lookup_logic(space, w_obj, w_descr, w_name)
+        if w_value is None:
+            w_value = space.getattr(w_obj, w_name)
         f.pushvalue(w_value)
         f.pushvalue(None)
 
@@ -68,37 +66,3 @@
         finally:
             f.dropvalues(nargs + 2)
         f.pushvalue(w_result)
-
-
-def object_getattribute(space):
-    w_src, w_getattribute = space.lookup_in_type_where(space.w_object,
-                                                       '__getattribute__')
-    return w_getattribute
-object_getattribute._annspecialcase_ = 'specialize:memo'
-
-
-def default_getattribute(space, w_obj, w_descr, w_name):
-    # code copied from descroperation.Object.descr__getattribute__()
-    if w_descr is not None:
-        if space.is_data_descr(w_descr):
-            return space.get(w_descr, w_obj)
-        w_value = w_obj.getdictvalue_attr_is_in_class(space, w_name)
-    else:
-        w_value = w_obj.getdictvalue(space, w_name)
-    if w_value is not None:
-        return w_value
-    if w_descr is not None:
-        return space.get(w_descr, w_obj)
-    raiseattrerror(space, w_obj, space.str_w(w_name))
-
-def default_lookup_logic(space, w_obj, w_descr, w_name):
-    # code copied from descroperation.DescrOperation.getattr()
-    try:
-        return default_getattribute(space, w_obj, w_descr, w_name)
-    except OperationError, e:
-        if not e.match(space, space.w_AttributeError):
-            raise
-        w_descr = space.lookup(w_obj, '__getattr__')
-        if w_descr is None:
-            raise
-        return space.get_and_call_function(w_descr, w_obj, w_name)



More information about the Pypy-commit mailing list