[Solved] RecursionError: maximum recursion depth exceeded in comparison

It is found that the default recursion depth of Python is very limited (the default is 1000), so when the recursion depth exceeds 999, such an exception will be thrown.

Solution:

You can modify the value of recursion depth to make it larger

import sys

Sys.setrecursionlimit (100000) # for example, it is set to 100000 here

be careful:

This solution is not the root cause, but also needs to be optimized in the code.

Read More: