What is the best way performance wise to take a list of words and turn them into phrases in python.
words = ["hey","there","stack","overflow"]
print magicFunction(words)
>>> ["hey","there","stack","overflow", "hey there stack","hey there", "there stack overflow","there stack", "stack overflow", "hey there stack overflow" ]
Order doesnt matter....
UPDATE: Should have been more specific, the words have to be consecutive, as in the list as in my example print out. So we could have "hey there" but not "hey stack"