Author: Carl Friedrich Bolz <cfb...@gmx.de>
Branch: remove-objspace-options
Changeset: r83814:c0ee63ae450b
Date: 2016-04-22 09:46 +0300
http://bitbucket.org/pypy/pypy/changeset/c0ee63ae450b/

Log:    remove withmethodcache option and have it always be on

diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -228,14 +228,10 @@
                    "enable optimized ways to store lists of primitives ",
                    default=True),
 
-        BoolOption("withmethodcache",
-                   "try to cache method lookups",
-                   default=False),
         BoolOption("withmethodcachecounter",
                    "try to cache methods and provide a counter in __pypy__. "
                    "for testing purposes only.",
-                   default=False,
-                   requires=[("objspace.std.withmethodcache", True)]),
+                   default=False),
         IntOption("methodcachesizeexp",
                   " 2 ** methodcachesizeexp is the size of the of the method 
cache ",
                   default=11),
@@ -273,7 +269,6 @@
     """
     # all the good optimizations for PyPy should be listed here
     if level in ['2', '3', 'jit']:
-        config.objspace.std.suggest(withmethodcache=True)
         config.objspace.std.suggest(intshortcut=True)
         config.objspace.std.suggest(optimized_list_getitem=True)
         config.objspace.std.suggest(getattributeshortcut=True)
diff --git a/pypy/doc/config/objspace.std.methodcachesizeexp.txt 
b/pypy/doc/config/objspace.std.methodcachesizeexp.txt
--- a/pypy/doc/config/objspace.std.methodcachesizeexp.txt
+++ b/pypy/doc/config/objspace.std.methodcachesizeexp.txt
@@ -1,1 +1,1 @@
-Set the cache size (number of entries) for 
:config:`objspace.std.withmethodcache`.
+Set the cache size (number of entries) for the method cache.
diff --git a/pypy/doc/config/objspace.std.withmethodcachecounter.txt 
b/pypy/doc/config/objspace.std.withmethodcachecounter.txt
--- a/pypy/doc/config/objspace.std.withmethodcachecounter.txt
+++ b/pypy/doc/config/objspace.std.withmethodcachecounter.txt
@@ -1,1 +1,1 @@
-Testing/debug option for :config:`objspace.std.withmethodcache`.
+Testing/debug option for the method cache.
diff --git a/pypy/doc/interpreter-optimizations.rst 
b/pypy/doc/interpreter-optimizations.rst
--- a/pypy/doc/interpreter-optimizations.rst
+++ b/pypy/doc/interpreter-optimizations.rst
@@ -133,8 +133,7 @@
 base classes is changed). On subsequent lookups the cached version can be used,
 as long as the instance did not shadow any of its classes attributes.
 
-You can enable this feature with the :config:`objspace.std.withmethodcache`
-option.
+This feature is enabled by default.
 
 
 Interpreter Optimizations
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -67,12 +67,7 @@
 
     @jit.elidable
     def find_map_attr(self, name, index):
-        if (self.space.config.objspace.std.withmethodcache):
-            return self._find_map_attr_cache(name, index)
-        return self._find_map_attr(name, index)
-
-    @jit.dont_look_inside
-    def _find_map_attr_cache(self, name, index):
+        # attr cache
         space = self.space
         cache = space.fromcache(MapAttrCache)
         SHIFT2 = r_uint.BITS - space.config.objspace.std.methodcachesizeexp
@@ -429,7 +424,6 @@
 
 class MapAttrCache(object):
     def __init__(self, space):
-        assert space.config.objspace.std.withmethodcache
         SIZE = 1 << space.config.objspace.std.methodcachesizeexp
         self.attrs = [None] * SIZE
         self.names = [None] * SIZE
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,7 +1115,6 @@
         class std:
             withsmalldicts = False
             withcelldict = False
-            withmethodcache = False
             withidentitydict = False
             withmapdict = False
 
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,7 +6,6 @@
         class std:
             withsmalldicts = False
             withcelldict = False
-            withmethodcache = False
             withidentitydict = False
             withmapdict = 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
@@ -68,7 +68,6 @@
 class MethodCache(object):
 
     def __init__(self, space):
-        assert space.config.objspace.std.withmethodcache
         SIZE = 1 << space.config.objspace.std.methodcachesizeexp
         self.versions = [None] * SIZE
         self.names = [None] * SIZE
@@ -352,17 +351,11 @@
     def lookup(w_self, name):
         # note that this doesn't call __get__ on the result at all
         space = w_self.space
-        if space.config.objspace.std.withmethodcache:
-            return w_self.lookup_where_with_method_cache(name)[1]
-
-        return w_self._lookup(name)
+        return w_self.lookup_where_with_method_cache(name)[1]
 
     def lookup_where(w_self, name):
         space = w_self.space
-        if space.config.objspace.std.withmethodcache:
-            return w_self.lookup_where_with_method_cache(name)
-
-        return w_self._lookup_where(name)
+        return w_self.lookup_where_with_method_cache(name)
 
     @unroll_safe
     def lookup_starting_at(w_self, w_starttype, name):
@@ -412,7 +405,6 @@
     def lookup_where_with_method_cache(w_self, name):
         space = w_self.space
         promote(w_self)
-        assert space.config.objspace.std.withmethodcache
         version_tag = promote(w_self.version_tag())
         if version_tag is None:
             tup = w_self._lookup_where(name)
@@ -424,10 +416,7 @@
         return tup_w   # don't make a new tuple, reuse the old one
 
     def _pure_lookup_where_possibly_with_method_cache(w_self, name, 
version_tag):
-        if w_self.space.config.objspace.std.withmethodcache:
-            return w_self._pure_lookup_where_with_method_cache(name, 
version_tag)
-        else:
-            return w_self._lookup_where_all_typeobjects(name)
+        return w_self._pure_lookup_where_with_method_cache(name, version_tag)
 
     @elidable
     def _pure_lookup_where_with_method_cache(w_self, name, version_tag):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to