From c8db7b619ccc974ff2ffaa1211f3d70450feabe6 Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Fri, 5 Jun 2015 17:54:54 +0200 Subject: [PATCH] Replace temp lists with iterators --- relational/relation.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/relational/relation.py b/relational/relation.py index a3bea88..928cca6 100644 --- a/relational/relation.py +++ b/relational/relation.py @@ -21,6 +21,7 @@ # relational operations on them. import csv +from itertools import chain from relational.rtypes import * @@ -171,9 +172,7 @@ class relation (object): # Create the body for i in self.content: - row = [] - for j in ids: - row.append(i[j]) + row = (i[j] for j in ids) newt.content.add(tuple(row)) return newt @@ -374,10 +373,7 @@ class relation (object): match = match and (i[sid[k]] == j[oid[k]]) if match: - item = list(i) - for l in noid: - item.append(j[l]) - + item = chain(i, (j[l] for l in noid)) newt.content.add(tuple(item)) return newt