title: Running maximum of numpy array values
body: <p>I need a fast way to keep a running maximum of a numpy array. For example, if my array was:</p>
  
  <pre><code>x = numpy.array([11,12,13,20,19,18,17,18,23,21])
  </code></pre>
  
  <p>I'd want:</p>
  
  <pre><code>numpy.array([11,12,13,20,20,20,20,20,23,23])
  </code></pre>
  
  <p>Obviously I could do this with a little loop:</p>
  
  <pre><code>def running_max(x):
      result = [x[0]]
      for val in x:
          if val &gt; result[-1]:
              result.append(val)
          else:
              result.append(result[-1])
      return result
  </code></pre>
  
  <p>But my arrays have hundreds of thousands of entries and I need to call this many times. It seems like there's got to be a numpy trick to remove the loop, but I can't seem to find anything that will work. The alternative will be to write this as a C extension, but it seems like I'd be reinventing the wheel.</p>