title: Does Python optimize tail recursion?
body: <p>I have the following piece of code which fails with the following error:</p>
  
  <blockquote>
    <p>RuntimeError: maximum recursion depth exceeded</p>
  </blockquote>
  
  <p>I attempted to rewrite this to allow for tail recursion optimization (TCO). I believe that this code should have been successful if a TCO had taken place.</p>
  
  <pre><code>def trisum(n, csum):
      if n == 0:
          return csum
      else:
          return trisum(n - 1, csum + n)
  
  print(trisum(1000, 0))
  </code></pre>
  
  <p>Should I conclude that Python does not do any type of TCO, or do I just need to define it differently?</p>