Author: Armin Rigo <[email protected]>
Branch: use-gc-del-3
Changeset: r84258:807ed074327d
Date: 2016-05-06 11:08 +0200
http://bitbucket.org/pypy/pypy/changeset/807ed074327d/
Log: No point in caching in typedef.py a subclass per space. The space is
not used any more. So we can as well cache a single global subclass.
diff --git a/pypy/interpreter/test/test_typedef.py
b/pypy/interpreter/test/test_typedef.py
--- a/pypy/interpreter/test/test_typedef.py
+++ b/pypy/interpreter/test/test_typedef.py
@@ -127,10 +127,7 @@
""" % (slots, methodname, checks[0], checks[1],
checks[2], checks[3]))
subclasses = {}
- for key, subcls in typedef._subclass_cache.items():
- if key[0] is not space.config:
- continue
- cls = key[1]
+ for cls, subcls in typedef._unique_subclass_cache.items():
subclasses.setdefault(cls, {})
prevsubcls = subclasses[cls].setdefault(subcls.__name__, subcls)
assert subcls is prevsubcls
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -108,18 +108,17 @@
def get_unique_interplevel_subclass(space, cls):
"NOT_RPYTHON: initialization-time only"
assert cls.typedef.acceptable_as_base_class
- key = space, cls
try:
- return _subclass_cache[key]
+ return _unique_subclass_cache[cls]
except KeyError:
- subcls = _getusercls(space, cls)
- assert key not in _subclass_cache
- _subclass_cache[key] = subcls
+ subcls = _getusercls(cls)
+ assert cls not in _unique_subclass_cache
+ _unique_subclass_cache[cls] = subcls
return subcls
get_unique_interplevel_subclass._annspecialcase_ = "specialize:memo"
-_subclass_cache = {}
+_unique_subclass_cache = {}
-def _getusercls(space, cls, reallywantdict=False):
+def _getusercls(cls, reallywantdict=False):
from rpython.rlib import objectmodel
from pypy.objspace.std.objectobject import W_ObjectObject
from pypy.module.__builtin__.interp_classobj import W_InstanceObject
diff --git a/pypy/module/__builtin__/interp_classobj.py
b/pypy/module/__builtin__/interp_classobj.py
--- a/pypy/module/__builtin__/interp_classobj.py
+++ b/pypy/module/__builtin__/interp_classobj.py
@@ -187,7 +187,7 @@
return
self.InstanceObjectCls = _getusercls(
- space, W_InstanceObject, reallywantdict=True)
+ W_InstanceObject, reallywantdict=True)
def class_descr_call(space, w_self, __args__):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit