From e375a65ec608a78fb6d1d51e2afff9e445aa5f19 Mon Sep 17 00:00:00 2001 From: LtWorf Date: Wed, 22 Sep 2010 13:31:19 +0000 Subject: [PATCH] - 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 --- CHANGELOG | 1 + relational/relation.py | 11 ++++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a371186..903a16a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/relational/relation.py b/relational/relation.py index d623ff9..854f39a 100644 --- a/relational/relation.py +++ b/relational/relation.py @@ -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