Well, it does not already exists, but it's been researched on SO already, for crosswords problems.
The gist of the solution I proposed was to index by letter and indexes, which is Python gives:
class Index:
def __init__(self, list):
self.data = defaultdict(set)
for word in list: self.add(word)
def add(self, word):
for l in range(0, len(word)):
self.data[(l, word[l])].insert(word)
def look(self, letters):
"""letters is a list of tuples (position, letter)"""
result = None
for (p,l) in letters:
set = self.data[(p,l)]
if result == None: result = set
else: result = result.insersection(set)
return result
The idea is simple: you have a large index which has a set of words for each couple (position,letter)
. It could be extended, in your case, to have one index per word length, which would dimish the size of the sets of words and thus be faster.
For retrieval, you simply intersect all the sets to have the common set of word that matches all the known letters.