Mike Meyer wrote:
> def my_search(another, keys, x):
>    return dict([[k, v] for k, v in another.items() if v >= x and k in keys])
>
> But then you're looking through all the keys in another, and searching
> through keys multiple times, which probably adds up to a lot more
> wasted work than indexing another twice.
Would you mind clarify ? Do you mean "k in keys" is a scan rather than
a lookup ? I find it to be pretty clean and straight forward.

I think one way or another, one need to loop through one of them, then
index search the other. It may help a bit to take the len() and loop
through the shorter one.

This seems like a SQL equivalent.

select * from a where a.key=b.key and a.v >= x

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to