Author: Carl Friedrich Bolz <cfb...@gmx.de>
Branch: remove-objspace-options
Changeset: r83819:75a6a2b7379e
Date: 2016-04-22 10:21 +0300
http://bitbucket.org/pypy/pypy/changeset/75a6a2b7379e/

Log:    remove getattributeshortcut option and turn it on by default

diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -220,9 +220,7 @@
 
         BoolOption("withmapdict",
                    "make instances really small but slow without the JIT",
-                   default=False,
-                   requires=[("objspace.std.getattributeshortcut", True),
-                       ]),
+                   default=False),
 
         BoolOption("withliststrategies",
                    "enable optimized ways to store lists of primitives ",
@@ -242,9 +240,6 @@
         BoolOption("optimized_list_getitem",
                    "special case the 'list[integer]' expressions",
                    default=False),
-        BoolOption("getattributeshortcut",
-                   "track types that override __getattribute__",
-                   default=False),
         BoolOption("newshortcut",
                    "cache and shortcut calling __new__ from builtin types",
                    default=False),
@@ -266,7 +261,6 @@
     if level in ['2', '3', 'jit']:
         config.objspace.std.suggest(intshortcut=True)
         config.objspace.std.suggest(optimized_list_getitem=True)
-        config.objspace.std.suggest(getattributeshortcut=True)
         #config.objspace.std.suggest(newshortcut=True)
         config.objspace.std.suggest(withspecialisedtuple=True)
         #if not IS_64_BITS:
diff --git a/pypy/doc/config/objspace.std.getattributeshortcut.txt 
b/pypy/doc/config/objspace.std.getattributeshortcut.txt
deleted file mode 100644
--- a/pypy/doc/config/objspace.std.getattributeshortcut.txt
+++ /dev/null
@@ -1,1 +0,0 @@
-Performance only: track types that override __getattribute__.
diff --git a/pypy/module/gc/interp_gc.py b/pypy/module/gc/interp_gc.py
--- a/pypy/module/gc/interp_gc.py
+++ b/pypy/module/gc/interp_gc.py
@@ -7,14 +7,13 @@
 def collect(space, generation=0):
     "Run a full collection.  The optional argument is ignored."
     # First clear the method cache.  See test_gc for an example of why.
-    if space.config.objspace.std.withmethodcache:
-        from pypy.objspace.std.typeobject import MethodCache
-        cache = space.fromcache(MethodCache)
+    from pypy.objspace.std.typeobject import MethodCache
+    cache = space.fromcache(MethodCache)
+    cache.clear()
+    if space.config.objspace.std.withmapdict:
+        from pypy.objspace.std.mapdict import MapAttrCache
+        cache = space.fromcache(MapAttrCache)
         cache.clear()
-        if space.config.objspace.std.withmapdict:
-            from pypy.objspace.std.mapdict import MapAttrCache
-            cache = space.fromcache(MapAttrCache)
-            cache.clear()
     rgc.collect()
     return space.wrap(0)
 
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
@@ -517,7 +517,6 @@
         return self.int_w(l_w[0]), self.int_w(l_w[1]), self.int_w(l_w[2])
 
     _DescrOperation_is_true = is_true
-    _DescrOperation_getattr = getattr
 
     def is_true(self, w_obj):
         # a shortcut for performance
@@ -526,8 +525,6 @@
         return self._DescrOperation_is_true(w_obj)
 
     def getattr(self, w_obj, w_name):
-        if not self.config.objspace.std.getattributeshortcut:
-            return self._DescrOperation_getattr(w_obj, w_name)
         # an optional shortcut for performance
 
         w_type = self.type(w_obj)
diff --git a/pypy/objspace/std/test/test_callmethod.py 
b/pypy/objspace/std/test/test_callmethod.py
--- a/pypy/objspace/std/test/test_callmethod.py
+++ b/pypy/objspace/std/test/test_callmethod.py
@@ -97,21 +97,17 @@
             else:
                 raise Exception("did not raise?")
         """
-    
+
     def test_kwargs(self):
         exec """if 1:
             class C(object):
                 def f(self, a):
                     return a + 2
-            
+
             assert C().f(a=3) == 5
         """
 
 
-class AppTestCallMethodWithGetattributeShortcut(AppTestCallMethod):
-    spaceconfig = {"objspace.std.getattributeshortcut": True}
-
-
 class TestCallMethod:
     def test_space_call_method(self):
         space = self.space
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
@@ -1115,6 +1115,8 @@
         class std:
             withcelldict = False
             withmapdict = False
+            methodcachesizeexp = 11
+            withmethodcachecounter = False
 
 FakeSpace.config = Config()
 
diff --git a/pypy/objspace/std/test/test_mapdict.py 
b/pypy/objspace/std/test/test_mapdict.py
--- a/pypy/objspace/std/test/test_mapdict.py
+++ b/pypy/objspace/std/test/test_mapdict.py
@@ -6,6 +6,8 @@
         class std:
             withcelldict = False
             withmapdict = True
+            methodcachesizeexp = 11
+            withmethodcachecounter = False
 
 space = FakeSpace()
 space.config = Config
diff --git a/pypy/objspace/std/test/test_typeobject.py 
b/pypy/objspace/std/test/test_typeobject.py
--- a/pypy/objspace/std/test/test_typeobject.py
+++ b/pypy/objspace/std/test/test_typeobject.py
@@ -1105,7 +1105,6 @@
 
 
 class AppTestGetattributeShortcut:
-    spaceconfig = {"objspace.std.getattributeshortcut": True}
 
     def test_reset_logic(self):
         class X(object):
diff --git a/pypy/objspace/std/test/test_userobject.py 
b/pypy/objspace/std/test/test_userobject.py
--- a/pypy/objspace/std/test/test_userobject.py
+++ b/pypy/objspace/std/test/test_userobject.py
@@ -273,13 +273,3 @@
             i += 1
 
 
-class AppTestWithGetAttributeShortcut(AppTestUserObject):
-    spaceconfig = {"objspace.std.getattributeshortcut": True}
-
-
-class AppTestDescriptorWithGetAttributeShortcut(
-    test_descriptor.AppTest_Descriptor):
-    # for the individual tests see
-    # ====> ../../test/test_descriptor.py
-
-    spaceconfig = {"objspace.std.getattributeshortcut": True}
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
@@ -135,7 +135,7 @@
                           'mro_w?[*]',
                           ]
 
-    # for config.objspace.std.getattributeshortcut
+    # wether the class has an overridden __getattribute__
     # (False is a conservative default, fixed during real usage)
     uses_object_getattribute = False
 
@@ -196,9 +196,8 @@
         space = w_self.space
         assert w_self.is_heaptype() or w_self.is_cpytype()
 
-        if space.config.objspace.std.getattributeshortcut:
-            w_self.uses_object_getattribute = False
-            # ^^^ conservative default, fixed during real usage
+        w_self.uses_object_getattribute = False
+        # ^^^ conservative default, fixed during real usage
 
         if (key is None or key == '__eq__' or
             key == '__cmp__' or key == '__hash__'):
@@ -230,15 +229,13 @@
         the one from object, in which case it returns None """
         from pypy.objspace.descroperation import object_getattribute
         if not we_are_jitted():
-            shortcut = w_self.space.config.objspace.std.getattributeshortcut
-            if not shortcut or not w_self.uses_object_getattribute:
+            if not w_self.uses_object_getattribute:
                 # slow path: look for a custom __getattribute__ on the class
                 w_descr = w_self.lookup('__getattribute__')
                 # if it was not actually overriden in the class, we remember 
this
                 # fact for the next time.
                 if w_descr is object_getattribute(w_self.space):
-                    if shortcut:
-                        w_self.uses_object_getattribute = True
+                    w_self.uses_object_getattribute = True
                 else:
                     return w_descr
             return None
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to