Writing the first examples in a more idiomatic style would better demonstrate the timing differences.  The list construction isn&#x27;t really noticeable at that size.<p><pre><code>  def generate(num):
      for i in xrange(num):
          yield random.randrange(10)

  def create_list(num):
      return [random.randrange(10) for i in xrange(num)]
</code></pre>
Also worth noting that functional programming in Python (e.g. inlining loops) is often faster.<p><pre><code>  from future_builtins import map
  import itertools

  def generate(num):
      return map(random.randrange, itertools.repeat(10, num))</code></pre>