[pypy-commit] pypy identity-dict-strategy: rename the option to withidentitydict

antocuni noreply at buildbot.pypy.org
Wed Jul 20 14:59:59 CEST 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: identity-dict-strategy
Changeset: r45772:deabe6d95200
Date: 2011-07-20 12:01 +0200
http://bitbucket.org/pypy/pypy/changeset/deabe6d95200/

Log:	rename the option to withidentitydict

diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -327,8 +327,8 @@
         BoolOption("mutable_builtintypes",
                    "Allow the changing of builtin types", default=False,
                    requires=[("objspace.std.builtinshortcut", True)]),
-        BoolOption("trackcomparebyidentity",
-                   "track types that override __hash__, __eq__ or __cmp__",
+        BoolOption("withidentitydict",
+                   "track types that override __hash__, __eq__ or __cmp__ and use a special dict strategy for those which do not",
                    default=True),
      ]),
 ])
diff --git a/pypy/objspace/std/dictmultiobject.py b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -157,14 +157,14 @@
        return self.erase(None)
 
     def switch_to_correct_strategy(self, w_dict, w_key):
-        trackcomparebyidentity = self.space.config.objspace.std.trackcomparebyidentity
+        withidentitydict = self.space.config.objspace.std.withidentitydict
         if type(w_key) is self.space.StringObjectCls:
             self.switch_to_string_strategy(w_dict)
             return
         w_type = self.space.type(w_key)
         if self.space.is_w(w_type, self.space.w_int):
             self.switch_to_int_strategy(w_dict)
-        elif trackcomparebyidentity and w_type.compares_by_identity():
+        elif withidentitydict and w_type.compares_by_identity():
             self.switch_to_identity_strategy(w_dict)
         else:
             self.switch_to_object_strategy(w_dict)
diff --git a/pypy/objspace/std/identitydict.py b/pypy/objspace/std/identitydict.py
--- a/pypy/objspace/std/identitydict.py
+++ b/pypy/objspace/std/identitydict.py
@@ -6,11 +6,11 @@
 # actual work is done by W_TypeObject.mutated() and objecttype:descr_setclass
 
 def bump_global_version(space):
-    if space.config.objspace.std.trackcomparebyidentity:
+    if space.config.objspace.std.withidentitydict:
         space.fromcache(ComparesByIdentityVersion).bump()
 
 def get_global_version(space):
-    if space.config.objspace.std.trackcomparebyidentity:
+    if space.config.objspace.std.withidentitydict:
         return space.fromcache(ComparesByIdentityVersion).get()
     return None
 
diff --git a/pypy/objspace/std/objecttype.py b/pypy/objspace/std/objecttype.py
--- a/pypy/objspace/std/objecttype.py
+++ b/pypy/objspace/std/objecttype.py
@@ -43,7 +43,7 @@
     assert isinstance(w_oldcls, W_TypeObject)
     if w_oldcls.get_full_instance_layout() == w_newcls.get_full_instance_layout():
         w_obj.setclass(space, w_newcls)
-        if space.config.objspace.std.trackcomparebyidentity:
+        if space.config.objspace.std.withidentitydict:
             if w_oldcls.compares_by_identity() and not w_newcls.compares_by_identity():
                 identitydict.bump_global_version(space)
     else:
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
@@ -1109,7 +1109,7 @@
 
 class AppTestIdentityDict(object):
     def setup_class(cls):
-        cls.space = gettestobjspace(**{"objspace.std.trackcomparebyidentity": True})
+        cls.space = gettestobjspace(**{"objspace.std.withidentitydict": True})
         if option.runappdirect:
             py.test.skip("__repr__ doesn't work on appdirect")
 
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
@@ -1201,12 +1201,12 @@
         assert a.f(1) == 2
 
 
-class AppTestTrackCompareByIdentity:
+class AppTestWithIdentityDict:
 
     def setup_class(cls):
         from pypy.objspace.std import identitydict
         cls.space = gettestobjspace(
-                        **{"objspace.std.trackcomparebyidentity": True})
+                        **{"objspace.std.withidentitydict": True})
 
         def compares_by_identity(space, w_cls):
             return space.wrap(w_cls.compares_by_identity())
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
@@ -107,7 +107,7 @@
     # (False is a conservative default, fixed during real usage)
     uses_object_getattribute = False
 
-    # for config.objspace.std.trackcomparebyidentity
+    # for config.objspace.std.withidentitydict
     compares_by_identity_status = UNKNOWN
 
     # used to cache the type __new__ function if it comes from a builtin type
@@ -164,7 +164,7 @@
         assert w_self.is_heaptype() or space.config.objspace.std.mutable_builtintypes
         if (not space.config.objspace.std.withtypeversion and
             not space.config.objspace.std.getattributeshortcut and
-            not space.config.objspace.std.trackcomparebyidentity and
+            not space.config.objspace.std.withidentitydict and
             not space.config.objspace.std.newshortcut):
             return
 
@@ -172,7 +172,7 @@
             w_self.uses_object_getattribute = False
             # ^^^ conservative default, fixed during real usage
 
-        if space.config.objspace.std.trackcomparebyidentity:
+        if space.config.objspace.std.withidentitydict:
             did_compare_by_identity = (
                 w_self.compares_by_identity_status == COMPARES_BY_IDENTITY)
             if (key is None or key == '__eq__' or
@@ -232,8 +232,7 @@
 
     def compares_by_identity(w_self):
         from pypy.objspace.descroperation import object_hash
-        track = w_self.space.config.objspace.std.trackcomparebyidentity
-        if not track:
+        if not w_self.space.config.objspace.std.withidentitydict:
             return False # conservative
         #
         if w_self.compares_by_identity_status != UNKNOWN:


More information about the pypy-commit mailing list