From 766a3a65272d93e2a6c7fd128563bf1b6eec5efa Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Mon, 1 Jun 2015 08:45:29 +0200 Subject: [PATCH] Simplified delete method --- relational/relation.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/relational/relation.py b/relational/relation.py index 47728ca..d4edb02 100644 --- a/relational/relation.py +++ b/relational/relation.py @@ -495,19 +495,13 @@ class relation (object): This operation will change the relation itself instead of generating a new one, deleting all the tuples that make expr true. Returns the number of affected rows.''' - self._make_writable() - attributes = {} - affected = len(self.content) - new_content = set() # New content of the relation - for i in self.content: - for j in range(len(self.header.attributes)): - attributes[self.header.attributes[j]] = self._autocast(i[j]) - if not eval(expr, attributes): - affected -= 1 - new_content.add(i) - self.content = new_content - return affected + #Not necessary self._make_writable() + + l = len(self.content) + self._readonly = False + self.content = self.difference(self.selection(expr)).content + return len(self.content) - l class header (object):