title: Avoid overflow when adding numpy arrays
body: <p>I want to add numpy arrays with datatyp uint8. I know that the values in these arrays may be large enough for an overflow to happen. So I get something like:</p>
  
  <pre><code>a = np.array([100, 200, 250], dtype=np.uint8)
  b = np.array([50, 50, 50], dtype=np.uint8)
  a += b
  </code></pre>
  
  <p>Now, a is <code>[150 250  44]</code>. However, instead of an overflow I want values which are too large for uint8 to be the maximum allowed for uint8. So my desired result would be <code>[150 250 255]</code>.</p>
  
  <p>I could get this result with the following code:</p>
  
  <pre><code>a = np.array([100, 200, 250], dtype=np.uint8)
  b = np.array([50, 50, 50], dtype=np.uint8)
  c = np.zeros((1,3), dtype=np.uint16)
  c += a
  c += b
  c[c&gt;255] = 255
  a = np.array(c, dtype=np.uint8)
  </code></pre>
  
  <p>The problem is, that my arrays are really big so creating a third array with a larger datatype could be a memory issue. Is there a fast and more memory efficient way to achieve the described result?</p>