title: maximum recursion depth exceeded in comparison?
body: <p>Started learning python, this is maximum sum subarray i have tried. Ending up with "maximum recursion depth exceeded in comparison". My algorithm seems ok to me. Please help me if im doing anything wrong. </p>
  
  <pre><code>import sys
  import math
  def maxtuple(lss,rss):
      if lss[2] &gt; rss[2]:
          return lss
      else:
          return rss
  def crosssubarray(A, start, mid, end):
      ls=rs=-sys.maxsize
      maxleft=0
      maxright=0
      sum = 0;
      for i in reversed(range(start, mid)):
          sum = sum + A[i]
          print(i)
          if sum &gt; ls:
              ls = sum
              maxleft = i
      sum = 0
      for i in range(mid+1, end):
          sum = sum+ A[i]
          if sum &gt; rs:
              rs = sum
              maxright = i
      return (maxleft, maxright, ls+rs)
  
  def maxsubarray(A,start,end):
      if start == end:
          return (start,end,A[start])
      else:
          mid = (start+end)/2
          lss = maxsubarray(A, start, mid)
          rss = maxsubarray(A, mid+1, end)
          css = crosssubarray(A, start, mid, end)
          maxsub = maxtuple(lss,rss)
          maxall = maxtuple(maxsub, css)
          return maxall
  
  A = [13,-3,-25,20,-3,-16,-23,18,20,-7,12,-5,-22,15,-4,7]
  print(maxsubarray(A,0,15))
  </code></pre>