# HG changeset patch # User Paul Boddie # Date 1256515418 -3600 # Node ID ed407c965ea509dd8f12d01cb38623b3f9d482be # Parent 9f3f7c6148d8d564c34a88e4710576259350da3c Added comments, Attr.exposes_name method. diff -r 9f3f7c6148d8 -r ed407c965ea5 micropython/data.py --- a/micropython/data.py Mon Oct 26 00:26:07 2009 +0100 +++ b/micropython/data.py Mon Oct 26 01:03:38 2009 +0100 @@ -304,6 +304,9 @@ self.attributes_used.add(attrname) return self.attributes_used + def exposes_name(self, attrname): + return attrname in self.attributes_used + # Value-related methods. def get_contexts(self): diff -r 9f3f7c6148d8 -r ed407c965ea5 micropython/inspect.py --- a/micropython/inspect.py Mon Oct 26 00:26:07 2009 +0100 +++ b/micropython/inspect.py Mon Oct 26 01:03:38 2009 +0100 @@ -198,13 +198,20 @@ "Vacuum the given object 'obj'." for name, attr in obj.items(): + + # Only consider deleting entire unused objects or things accessible + # via names which are never used. + if delete_all or not self.importer.uses_name(name): del obj[name] + + # Delete any unambiguous attribute value. Such values can only + # have been defined within the object and therefore are not + # redefined by other code regions. + if attr.assignments == 1: value = attr.get_value() - # Delete any unambiguous attribute value. - if value is not obj and value in self.all_objects: self.all_objects.remove(value)