I have a list that looks like this:
l1 = [\'200:200\', \'90:728\']
I have a dictionary that looks like this:
d1 = {\'200:20
If memory allocation and deallocation is making this process take too long, itertools to the rescue.
import itertools
result = {dict_key:d1[dict_key] for dict_key in itertools.ifilter(lambda list_item: list_item in d1, l1) }
This doesn't unnecessarily allocate memory for a whole new collection, and l1 could easily be an iterator instead of a list.