* Fix broken _ObjectKey.__eq__() logic from previous commit.
authorZac Medico <zmedico@gentoo.org>
Sun, 24 Aug 2008 17:32:19 +0000 (17:32 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 24 Aug 2008 17:32:19 +0000 (17:32 -0000)
* Define _ObjectKey.__slots__ to save memory.

svn path=/main/trunk/; revision=11467

pym/portage/dbapi/vartree.py

index b3eefe8c456ddbb1cd7e3ae7f6079c59e8bf938b..598845e0bb9128fc920f62c59ffe2c451e82a45c 100644 (file)
@@ -153,6 +153,8 @@ class LinkageMap(object):
 
                """Helper class used as _obj_properties keys for objects."""
 
+               __slots__ = ("__weakref__", "_key")
+
                def __init__(self, object):
                        """
                        This takes a path to an object.
@@ -167,9 +169,11 @@ class LinkageMap(object):
                        return hash(self._key)
 
                def __eq__(self, other):
-                       if not isinstance(other, self.__class__):
-                               return False
-                       return self._key == other._key
+                       if isinstance(other, self.__class__):
+                               other_key = other._key
+                       else:
+                               other_key = other
+                       return self._key == other_key
 
                def _generate_object_key(self, object):
                        """