with open('words.txt') as inf:
    words = set(wd.strip() for wd in inf)
word_gen = ((word, word[::2], word[1::2]) for word in words)
interlocked = [word for word, a, b in word_gen if a in words and b in words]
How to optimize this Python code (from ThinkPython, Exercise 10.10)