title: What is the computational complexity of `itertools.combinations` in python?
body: <p><code>itertools.combinations</code> in python is a powerful tool for finding all combination of <em>r</em> terms, however, I want to know about its <strong>computational complexity</strong>. </p>
  
  <p>Let's say I want to know the complexity in terms of <em>n</em> and <em>r</em>, and certainly it will give me all the <em>r</em> terms combination from a list of <em>n</em> terms.</p>
  
  <p>According to the Official document, this is the rough implementation.</p>
  
  <pre><code>def combinations(iterable, r):
      # combinations('ABCD', 2) --&gt; AB AC AD BC BD CD
      # combinations(range(4), 3) --&gt; 012 013 023 123
      pool = tuple(iterable)
      n = len(pool)
      if r &gt; n:
          return
      indices = list(range(r))
      yield tuple(pool[i] for i in indices)
      while True:
          for i in reversed(range(r)):
              if indices[i] != i + n - r:
                  break
          else:
              return
          indices[i] += 1
          for j in range(i+1, r):
              indices[j] = indices[j-1] + 1
          yield tuple(pool[i] for i in indices)
  </code></pre>