Author: Carl Friedrich Bolz <[email protected]>
Branch: remove-objspace-options
Changeset: r83813:8af4c34be749
Date: 2016-04-21 19:49 +0300
http://bitbucket.org/pypy/pypy/changeset/8af4c34be749/

Log:    remove the withtypeversion 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
@@ -222,22 +222,15 @@
                    "make instances really small but slow without the JIT",
                    default=False,
                    requires=[("objspace.std.getattributeshortcut", True),
-                             ("objspace.std.withtypeversion", True),
                        ]),
 
         BoolOption("withliststrategies",
                    "enable optimized ways to store lists of primitives ",
                    default=True),
 
-        BoolOption("withtypeversion",
-                   "version type objects when changing them",
-                   cmdline=None,
-                   default=False),
-
         BoolOption("withmethodcache",
                    "try to cache method lookups",
-                   default=False,
-                   requires=[("objspace.std.withtypeversion", True)]),
+                   default=False),
         BoolOption("withmethodcachecounter",
                    "try to cache methods and provide a counter in __pypy__. "
                    "for testing purposes only.",
diff --git a/pypy/config/test/test_pypyoption.py 
b/pypy/config/test/test_pypyoption.py
--- a/pypy/config/test/test_pypyoption.py
+++ b/pypy/config/test/test_pypyoption.py
@@ -52,14 +52,6 @@
     set_pypy_opt_level(conf, '0')
     assert not conf.objspace.std.getattributeshortcut
 
-def test_rweakref_required():
-    conf = get_pypy_config()
-    conf.translation.rweakref = False
-    set_pypy_opt_level(conf, '3')
-
-    assert not conf.objspace.std.withtypeversion
-    assert not conf.objspace.std.withmethodcache
-
 def test_check_documentation():
     def check_file_exists(fn):
         assert configdocdir.join(fn).check()
diff --git a/pypy/objspace/std/test/test_versionedtype.py 
b/pypy/objspace/std/test/test_versionedtype.py
--- a/pypy/objspace/std/test/test_versionedtype.py
+++ b/pypy/objspace/std/test/test_versionedtype.py
@@ -1,7 +1,6 @@
 from pypy.objspace.std.test import test_typeobject
 
 class TestVersionedType(test_typeobject.TestTypeObject):
-    spaceconfig = {"objspace.std.withtypeversion": True}
 
     def get_three_classes(self):
         space = self.space
@@ -261,6 +260,3 @@
 
 
 
-class AppTestVersionedType(test_typeobject.AppTestTypeObject):
-    spaceconfig = {"objspace.std.withtypeversion": 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
@@ -38,9 +38,8 @@
 
 
 def unwrap_cell(space, w_value):
-    if space.config.objspace.std.withtypeversion:
-        if isinstance(w_value, MutableCell):
-            return w_value.unwrap_cell(space)
+    if isinstance(w_value, MutableCell):
+        return w_value.unwrap_cell(space)
     return w_value
 
 def write_cell(space, w_cell, w_value):
@@ -170,14 +169,13 @@
             layout = setup_user_defined_type(w_self, force_new_layout)
         w_self.layout = layout
 
-        if space.config.objspace.std.withtypeversion:
-            if not is_mro_purely_of_types(w_self.mro_w):
-                pass
-            else:
-                # the _version_tag should change, whenever the content of
-                # dict_w of any of the types in the mro changes, or if the mro
-                # itself changes
-                w_self._version_tag = VersionTag()
+        if not is_mro_purely_of_types(w_self.mro_w):
+            pass
+        else:
+            # the _version_tag should change, whenever the content of
+            # dict_w of any of the types in the mro changes, or if the mro
+            # itself changes
+            w_self._version_tag = VersionTag()
         if space.config.objspace.std.withmapdict:
             from pypy.objspace.std.mapdict import DictTerminator, 
NoDictTerminator
             if w_self.hasdict:
@@ -197,11 +195,6 @@
         """
         space = w_self.space
         assert w_self.is_heaptype() or w_self.is_cpytype()
-        if (not space.config.objspace.std.withtypeversion and
-            not space.config.objspace.std.getattributeshortcut and
-            not space.config.objspace.std.withidentitydict and
-            not space.config.objspace.std.newshortcut):
-            return
 
         if space.config.objspace.std.getattributeshortcut:
             w_self.uses_object_getattribute = False
@@ -215,8 +208,7 @@
         if space.config.objspace.std.newshortcut:
             w_self.w_new_function = None
 
-        if (space.config.objspace.std.withtypeversion
-            and w_self._version_tag is not None):
+        if w_self._version_tag is not None:
             w_self._version_tag = VersionTag()
 
         subclasses_w = w_self.get_subclasses()
@@ -296,13 +288,12 @@
         return compute_C3_mro(w_self.space, w_self)
 
     def getdictvalue(w_self, space, attr):
-        if space.config.objspace.std.withtypeversion:
-            version_tag = w_self.version_tag()
-            if version_tag is not None:
-                return unwrap_cell(
-                    space,
-                    w_self._pure_getdictvalue_no_unwrapping(
-                        space, version_tag, attr))
+        version_tag = w_self.version_tag()
+        if version_tag is not None:
+            return unwrap_cell(
+                space,
+                w_self._pure_getdictvalue_no_unwrapping(
+                    space, version_tag, attr))
         w_value = w_self._getdictvalue_no_unwrapping(space, attr)
         return unwrap_cell(space, w_value)
 
@@ -333,14 +324,13 @@
             msg = ("a __del__ method added to an existing type will not be "
                    "called")
             space.warn(space.wrap(msg), space.w_RuntimeWarning)
-        if space.config.objspace.std.withtypeversion:
-            version_tag = w_self.version_tag()
-            if version_tag is not None:
-                w_curr = w_self._pure_getdictvalue_no_unwrapping(
-                        space, version_tag, name)
-                w_value = write_cell(space, w_curr, w_value)
-                if w_value is None:
-                    return True
+        version_tag = w_self.version_tag()
+        if version_tag is not None:
+            w_curr = w_self._pure_getdictvalue_no_unwrapping(
+                    space, version_tag, name)
+            w_value = write_cell(space, w_curr, w_value)
+            if w_value is None:
+                return True
         w_self.mutated(name)
         w_self.dict_w[name] = w_value
         return True
@@ -429,8 +419,7 @@
             return tup
         tup_w = w_self._pure_lookup_where_with_method_cache(name, version_tag)
         w_class, w_value = tup_w
-        if (space.config.objspace.std.withtypeversion and
-                isinstance(w_value, MutableCell)):
+        if isinstance(w_value, MutableCell):
             return w_class, w_value.unwrap_cell(space)
         return tup_w   # don't make a new tuple, reuse the old one
 
@@ -524,7 +513,7 @@
     def issubtype(w_self, w_type):
         promote(w_self)
         promote(w_type)
-        if w_self.space.config.objspace.std.withtypeversion and 
we_are_jitted():
+        if we_are_jitted():
             version_tag1 = w_self.version_tag()
             version_tag2 = w_type.version_tag()
             if version_tag1 is not None and version_tag2 is not None:
@@ -843,8 +832,7 @@
             cls.mro_w = old_mro
         w_type.bases_w = saved_bases_w
         raise
-    if (space.config.objspace.std.withtypeversion and
-        w_type.version_tag() is not None and
+    if (w_type.version_tag() is not None and
         not is_mro_purely_of_types(w_type.mro_w)):
         # Disable method cache if the hierarchy isn't pure.
         w_type._version_tag = None
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to