What is the computational complexity of `itertools.combinations` in python?
itertools.combinations in python is a powerful tool for finding all combination of r terms, however, I want to know about its computational complexity . Let's say I want to know the complexity in terms of n and r , and certainly it will give me all the r terms combination from a list of n terms. According to the Official document, this is the rough implementation. def combinations(iterable, r): # combinations('ABCD', 2) --> AB AC AD BC BD CD # combinations(range(4), 3) --> 012 013 023 123 pool = tuple(iterable) n = len(pool) if r > n: return indices = list(range(r)) yield tuple(pool[i] for i