Use dictionary comprehension in selection

When doing a selection, a new context (in the form of a dictionary)
is created.

Instead of re-using the same dictionary re-assigning the values, now
use a comprehension to avoid redundant reads.
master
Salvo 'LtWorf' Tomaselli 2015-06-25 16:34:47 +07:00
parent bcc7053892
commit 95e375f44a
1 changed files with 1 additions and 3 deletions

@ -106,13 +106,11 @@ class relation (object):
def selection(self, expr):
'''Selection, expr must be a valid boolean expression, can contain field names,
constant, math operations and boolean ones.'''
attributes = {}
newt = relation()
newt.header = header(self.header)
for i in self.content:
# Fills the attributes dictionary with the values of the tuple
for j,attr in enumerate(self.header):
attributes[attr] = i[j].autocast()
attributes = {attr:i[j].autocast() for j, attr in enumerate(self.header)}
try:
if eval(expr, attributes):