"Jay Tee" <[EMAIL PROTECTED]> writes: > for j in jobs: > if (j.get('user') == 'jeff' and j.get('state')=='running') : > do_something()
Sounds like you need some backing data structures, like indexes in a database, e.g. (untested, uses the cool new defaultdicts of 2.5): index = defaultdict(lambda: defaultdict(set)) for j in jobs: for k in j's dict: index[k][j.get(k)].add(j) Now for > if j.subset_attr({'user' : 'jeff', 'state' : 'running'}) : > do_something() you'd just write: for j in (index['user']['jeff'] & index['state']['running']): do_something() -- http://mail.python.org/mailman/listinfo/python-list