What is the format of python pstats or lstat file? This is my understanding: The pstats file is marshalled dictionary object, with tuple of (filename, lineno, funcname) as keys and a tuple of (nc, cc, tt, ct, callers) elements as values. The values represent: (filename, lineno, funcname) - the function funcname is located in filename:lineno. nc - the number of calls to funcname cc - I have no idea, it is non-recursive or only recursive or primitive or non-primitive calls to funcname? which one is it? tt - this is the total time spent in the function excluding the time spent in subfunctions. What if that subfunction is recursive? Is it uncluded or not? ct - the total time spent in this function callers - the definition is recursive - callers is a dictionary of (filename, lineno, funcname) keys with (nc, cc, tt, ct, callers) as dictionary values. When a function is recursive, is each entry of the function added separately to the next level of callers and it nest recursively, or does only the "upper level" invokation keep all the recursively calls statistica accumulated? I have read the following links for research: https://github.com/python/cpython/blob/main/Lib/cProfile.py#L63 https://github.com/python/cpython/blob/main/Modules/_lsprof.c#L31 https://github.com/python/cpython/blob/main/Lib/pstats.py#L160 https://docs.python.org/3/library/profile.html In Python cProfile, what is the difference between calls count and primitive calls count? Continue reading...