0
votes

i want to make a program that return caller&callee for any java project.
i have this method:

def searchformethod(methodcalls,method):
    for call in methodcalls:
        if method in call[4]:
           calll=call[0],call[2]
           callerncallee.methodcaller.append(calll)
           callerncallee.searchformethod(methodcalls,call[2])

each call in methodcalls contain ("class",".","caller",".","callee")
i need a recursion to get every method it works fine in case of small projects,
but in case of large projects i got this

 callerncallee.searchformethod(methodcalls,call[2])
 [Previous line repeated 989 more times]
 RecursionError: maximum recursion depth exceeded
1

1 Answers

0
votes

Python has no optimization for tail recursion, this means for every recursion step the stack increases until the limit is reached. Then you get the error message like you got.

You have to convert the recursive call into an while loop.