title: Sum of two numbers with default maximum value that cannot be exceeded
body: <p>Suppose that I have a numeric variable which will have another value added to it, but I want to make sure that this variable never exceeds a maximum value, and upon being exceeded, will simply default to the maximum value.</p>
  
  <p>For example, given a maximum value of 100, and a function which does this which is called <code>maxadd</code>:</p>
  
  <pre><code>input1 = 90
  input2 = 8
  maxadd(input1, input2, 100)
  &gt;&gt;&gt; 98
  
  input1 = 95
  input2 = 8
  maxadd(input1, input2, 100)
  &gt;&gt;&gt; 100
  </code></pre>
  
  <p>I could just define it as a normal function like this:</p>
  
  <pre><code>def maxadd(a, b, _max):
      res = a + b
      if res &gt; _max:
          return _max
      return res
  </code></pre>
  
  <p>But I feel like it could be done in a single line, maybe with a lambda. I can't seem to figure anything out though. Performance is also a concern so I would like the fastest solution possible, and I feel like this function may be taking unnecessary steps</p>