Python quick sort, 10, 000, stack overflow

Quick code:

import sys
sys.setrecursionlimit(100000)
def mysqort(arr, low, high):

    if low >= high:
        return
    i = low
    j = high
    base = arr[low]
    while(i<j):
        while(i<j and arr[j] > base):
            j -= 1
        if(i<j):
            arr[i] = arr[j]
            i = i + 1
        while(i<j and arr[i] < base):
            i += 1
        if(i<j):
            arr[j] = arr[i]
            j -= 1
    arr[i] = base
    mysqort(arr,low,i-1)
    mysqort(arr,i+1,high)
-sharp10000
arr = list(range(10000))
-sharp
arr.reverse()
-sharp
mysqort(arr,0,9999)
-sharp
print(arr)

I am surprised that 10000 numbers can not be sorted. It is said on the Internet that there is a limit on the depth of recursion. Sys.setrecursionlimit (100000), which is also set here, why does the fast row of 10000 numbers overflow the stack?
wrote another recursion:

import sys
sys.setrecursionlimit(100000000)
def rec(n):
    print(n)
    rec(n+1)
rec(1)

print to 8657 starts to report stack overflow problems

Mar.22,2021

In addition to

python, there is an os limit. This should give a simple estimate of your system's limit:
python.org/projects/python/trunk/Tools/scripts/find_recursionlimit.py" rel=" nofollow noreferrer "> http://svn.python.org/project.

.

python-and-how-to-increase-it/18649326" rel=" nofollow noreferrer "> https://stackoverflow.com/que.

Menu