Skip to content

Conversation

seddonym
Copy link
Contributor

@seddonym seddonym commented Jan 2, 2025

This is just a quick experiment and shouldn't be merged.

The command uv run generate.py --chain-length=3 --recursion-limit=1000 will generate a module that looks like this:

import sys

sys.setrecursionlimit(1000)

print(f"Calling a chain of 3 functions with a recursion limit of 1000...")


def function_001():
    function_002()


def function_002():
    function_003()


def function_003():
    print("Got to the end of the call chain.")


if __name__ == "__main__":
    function_001()

Results

Unlike with import chains, each additional function call requires the recursion limit to be raised by 1:

E.g. with a recursion limit of 1000:

  File ".../import-recursion-demo/src/funcdemo.py", line 4001, in function_999
    function_1000()
RecursionError: maximum recursion depth exceeded

This is just a quick experiment and shouldn't be merged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant