title: How to create a 2D array of ranges using numpy
body: <p>I have an array of start and stop indices, like this:</p>
  
  <pre><code>    [[0, 3], [4, 7], [15, 18]]
  </code></pre>
  
  <p>and i would like to construct a 2D numpy array where each row is a range from the corresponding pair of start and stop indices, as follows:</p>
  
  <pre><code>    [[0, 1, 2],
      [4, 5, 6],
      [15, 16, 18]]
  </code></pre>
  
  <p>Currently, i am creating an empty array and filling it in a for loop:</p>
  
  <pre><code>    ranges = numpy.empty((3, 3))
      a = [[0, 3], [4, 7], [15, 18]]
  
      for i, r in enumerate(a):
          ranges[i] = numpy.arange(r[0], r[1])
  </code></pre>
  
  <p>Is there a more compact and (more importantly) faster way of doing this? possibly something that doesn't involve using a loop?</p>