[Zope-CVS] CVS: Packages/pypes/pypes - identity.py:1.12

Casey Duncan casey at zope.com
Mon Mar 1 23:14:29 EST 2004


Update of /cvs-repository/Packages/pypes/pypes
In directory cvs.zope.org:/tmp/cvs-serv11710

Modified Files:
	identity.py 
Log Message:
Add small optimization for __eq__ and __ne__ for identity sets


=== Packages/pypes/pypes/identity.py 1.11 => 1.12 ===
--- Packages/pypes/pypes/identity.py:1.11	Sun Feb 29 00:44:48 2004
+++ Packages/pypes/pypes/identity.py	Mon Mar  1 23:14:26 2004
@@ -255,7 +255,9 @@
     __and__ = intersection
     
     def issubset(self, other):
-        if isinstance(other, IdentitySet):
+        if self is other:
+            return True
+        elif isinstance(other, IdentitySet):
             return not difference(self._idset, other._idset)
         elif hasattr(other, 'issuperset'): # XXX Interface check instead?
             return other.issuperset(self)
@@ -263,7 +265,9 @@
             raise TypeError, 'wrong type for issubset'
     
     def issuperset(self, other):
-        if isinstance(other, IdentitySet):
+        if self is other:
+            return True
+        elif isinstance(other, IdentitySet):
             return not difference(other._idset, self._idset)
         elif hasattr(other, 'issubset'): # XXX Interface check instead?
             return other.issubset(self)




More information about the Zope-CVS mailing list