Author: Antonio Cuni <[email protected]>
Branch: identity-dict-strategy
Changeset: r45759:5ee41f314843
Date: 2011-07-20 10:16 +0200
http://bitbucket.org/pypy/pypy/changeset/5ee41f314843/
Log: as cfbolz points out, we cannot mutate the space, because it's
frozen. Instead, store the mutable version in an object attached to
the space
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
@@ -45,7 +45,7 @@
w_obj.setclass(space, w_newcls)
if space.config.objspace.std.trackcomparebyidentity:
if w_oldcls.compares_by_identity() and not
w_newcls.compares_by_identity():
- space.bump_compares_by_identity_version()
+ space.compares_by_identity_version.bump()
else:
raise operationerrfmt(space.w_TypeError,
"__class__ assignment: '%s' object layout
differs from '%s'",
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
@@ -89,7 +89,7 @@
self.w_classobj = self.builtin.get('__metaclass__')
if self.config.objspace.std.trackcomparebyidentity:
- self.bump_compares_by_identity_version()
+ self.compares_by_identity_version = ComparesByIdentityVersion()
# final setup
self.setup_builtin_modules()
@@ -581,5 +581,11 @@
return self.wrap(w_sub.issubtype(w_type))
raise OperationError(self.w_TypeError, self.wrap("need type objects"))
- def bump_compares_by_identity_version(self):
- self.compares_by_identity_version = VersionTag()
+
+class ComparesByIdentityVersion(object):
+
+ def __init__(self):
+ self.bump()
+
+ def bump(self):
+ self._version = VersionTag()
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
@@ -1212,7 +1212,7 @@
cls.w_compares_by_identity =
cls.space.wrap(interp2app(compares_by_identity))
def get_version(space):
- v = cls.versions.setdefault(space.compares_by_identity_version,
+ v =
cls.versions.setdefault(space.compares_by_identity_version._version,
len(cls.versions))
return space.wrap(v)
cls.w_get_version = cls.space.wrap(interp2app(get_version))
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
@@ -178,7 +178,7 @@
key == '__cmp__' or key == '__hash__'):
w_self.compares_by_identity_status = UNKNOWN
if did_compare_by_identity:
- w_self.space.bump_compares_by_identity_version()
+ w_self.space.compares_by_identity_version.bump()
if space.config.objspace.std.newshortcut:
w_self.w_bltin_new = None
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit