def combinations(input):
    ret = ['']
yield ''
for i in range(len(input)):
    for prefix in ret:
        combination = prefix + input[i]
ret.extend(combination)
yield combination
What's the most memory efficient way to generate the combinations of a set in python?