Membership testing is faster in dict than in list.¶
Python dictionaries use hash tables, this means that a lookup operation (e.g., if x in y) is O(1). A lookup operation in a list means that the entire list needs to be iterated, resulting in O(n) for a list of length n. http://www.clips.ua.ac.be/tutorials/python-performance-optimization