- Clearer and better code for handling relation comparisons

git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@252 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
LtWorf 2010-09-22 13:31:19 +00:00
parent d63d0e78c0
commit e375a65ec6
2 changed files with 5 additions and 7 deletions

View File

@ -2,6 +2,7 @@
- Removed encoding from .desktop file (was deprecated)
- Added manpage for relational-cli
- Internally uses set instead of lists to describe relation's content
- Tuples are internally mapped on tuples and no longer on lists
- Discards the old and not so functional tlb format
- Rename will mark the resulting relation as readonly and subsequent updates, insert or deletes will actually copy the content

View File

@ -381,16 +381,13 @@ class relation (object):
def __eq__(self,other):
'''Returns true if the relations are the same, ignoring order of items.
This operation is rather heavy, since it requires sorting and comparing.'''
other=self._rearrange_(other) #Rearranges attributes' order so can compare tuples directly
if (self.__class__!=other.__class__)or(self.header!=other.header):
return False #Both parameters must be a relation
if set(self.header.attributes)!=set(other.header.attributes):
return False
#Comparing header
if len(self.header.attributes) != len(other.header.attributes):
return False #Not the same number of attributes -> not equals
for i in self.header.attributes:
if i not in other.header.attributes:
return False #Non shared attribute
other=self._rearrange_(other) #Rearranges attributes' order so can compare tuples directly
#comparing content
return self.content==other.content