Speed in Python

Samuel Tardieu (sam@grasp.insa-lyon.fr)
12 Aug 1994 22:47:56 +0200

What's the fastest way to check if a word is in a given set of words ?
Should I do:

list = ['word1', 'word2', 'word3']
if i in list:
...

or

list = {'word1': None, 'word2': None, 'word3': None}
if list.has_key(i):
...

?

Of course, the word list is greater than 3 words.

Sam