Python | sys.setrecursionlimit() method Last Updated : 07 Aug, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report This sys module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter. It provides information about constants, functions and methods of python interpreter. It can be used for manipulating Python runtime environment. sys.setrecursionlimit() method is used to set the maximum depth of the Python interpreter stack to the required limit. This limit prevents any program from getting into infinite recursion, Otherwise infinite recursion will lead to overflow of the C stack and crash the Python. Note: The highest possible limit is platform-dependent. This should be done with care because too-high limit can lead to crash. Syntax: sys.setrecursionlimit(limit) Parameter: limit: It the value of integer type that denotes the new limit of python interpreter stack. Return Value: This method returns nothing. Example #1 : Python3 1== # Python program to explain sys.setrecursionlimit() method # Importing sys module import sys # Using sys.getrecursionlimit() method # to find the current recursion limit limit = sys.getrecursionlimit() # Print the current limit print('Before changing, limit of stack =', limit) # New limit Newlimit = 500 # Using sys.setrecursionlimit() method sys.setrecursionlimit(Newlimit) # Using sys.getrecursionlimit() method # to find the current recursion limit limit = sys.getrecursionlimit() # Print the current limit print('After changing, limit of stack =', limit) Output: Before changing, limit of stack = 1000 After changing, limit of stack = 500 Comment More infoAdvertise with us Next Article Python | os.setregid() method R Rajnis09 Follow Improve Article Tags : Python python-modules Practice Tags : python Similar Reads Python | sys.setswitchinterval() method This sys module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter. It provides information about constants, functions and methods of python interpreter. It can be used for manipulating Python runtime environment. sys. 2 min read Python | os.setregid() method OS module in Python provides functions for interacting with the operating system. OS comes under Pythonâs standard utility modules. This module provides a portable way of using operating system dependent functionality. All functions in os module raise OSError in the case of invalid or inaccessible f 3 min read Python | os.truncate() method OS module in Python provides functions for interacting with the operating system. OS comes under Pythonâs standard utility modules. This module provides a portable way of using operating system dependent functionality. os.truncate() method in Python is used to truncate the file indicated by the spec 4 min read Python | os.truncate() method os.truncate() method truncates the file corresponding to the path so that it is at the most length bytes in size. This function can support file descriptors too. In this article, we will learn about Python os.truncate() method. os.truncate() Method Syntax in PythonSyntax: os.truncate(path, length) P 3 min read Python | os.sysconf() method OS module in Python provides functions for interacting with the operating system. OS comes under Pythonâs standard utility modules. This module provides a portable way of using operating system dependent functionality. os.sysconf() method in Python is used to get integer-valued system configuration 4 min read Python File truncate() Method Prerequisites: File Objects in Python Reading and Writing to files in Python Truncate() method truncate the fileâs size. If the optional size argument is present, the file is truncated to (at most) that size. The size defaults to the current position. The current file position is not changed. Note t 2 min read Like