Author: Ronan Lamy <[email protected]>
Branch: no-class-specialize
Changeset: r80167:519e2de59249
Date: 2015-10-13 17:30 +0100
http://bitbucket.org/pypy/pypy/changeset/519e2de59249/

Log:    Store the now-unique classdef in a plain attribute rather than a
        length-1 dict

diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -162,9 +162,7 @@
             s_callable.consider_call_site(args, s_result, call_op)
 
     def getuniqueclassdef(self, cls):
-        """Get the ClassDef associated with the given user cls.
-        Avoid using this!  It breaks for classes that must be specialized.
-        """
+        """Get the ClassDef associated with the given user cls."""
         assert cls is not object
         desc = self.getdesc(cls)
         return desc.getuniqueclassdef()
diff --git a/rpython/annotator/description.py b/rpython/annotator/description.py
--- a/rpython/annotator/description.py
+++ b/rpython/annotator/description.py
@@ -433,7 +433,7 @@
             raise AnnotatorError(
                 "Class specialization has been removed. The "
                 "'_annspecialcase_' class tag is now unsupported.")
-        self._classdefs = {}
+        self.classdef = None
 
         if is_mixin(cls):
             raise AnnotatorError("cannot use directly the class %r because "
@@ -573,17 +573,14 @@
         for name, value in cls.__dict__.items():
             self.add_source_attribute(name, value)
 
-    def getallclassdefs(self):
-        return self._classdefs.values()
-
     def getclassdef(self, key):
-        try:
-            return self._classdefs[key]
-        except KeyError:
+        if self.classdef is not None:
+            return self.classdef
+        else:
             from rpython.annotator.classdef import ClassDef
             classdef = ClassDef(self.bookkeeper, self)
             self.bookkeeper.classdefs.append(classdef)
-            self._classdefs[key] = classdef
+            self.classdef = classdef
 
             # forced attributes
             cls = self.pyobj
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to