Python 如何理解py spy的此分析报告?

Python 如何理解py spy的此分析报告?,python,profiling,Python,Profiling,突然,我的程序在一次函数调用“make_doc”时变得非常慢,我的程序只做了一些小改动。我不明白它为什么变得这么慢。在“make_doc”中有一个很难调试的Cython代码 我尝试使用py spy来分析并生成了3个屏幕截图,但没有得到任何关于速度缓慢的线索。它似乎表明inspect.py中的“getmodule”方法花费的时间最多。这是真的吗?我从python 3.7 inspect.py的getmodule函数中复制了这部分代码: # Update the filename to module

突然,我的程序在一次函数调用“make_doc”时变得非常慢,我的程序只做了一些小改动。我不明白它为什么变得这么慢。在“make_doc”中有一个很难调试的Cython代码

我尝试使用py spy来分析并生成了3个屏幕截图,但没有得到任何关于速度缓慢的线索。它似乎表明inspect.py中的“getmodule”方法花费的时间最多。这是真的吗?我从python 3.7 inspect.py的getmodule函数中复制了这部分代码:

# Update the filename to module name cache and check yet again
    # Copy sys.modules in order to cope with changes while iterating
    for modname, module in sys.modules.copy().items():
        if ismodule(module) and hasattr(module, '__file__'):
            f = module.__file__
            if f == _filesbymodname.get(modname, None):
                # Have already mapped this module, so skip it
                continue
            _filesbymodname[modname] = f
            f = getabsfile(module)
            # Always map to the name the module knows itself by
            modulesbyfile[f] = modulesbyfile[
                os.path.realpath(f)] = module.__name__
这应该是由我自己的代码引起的?我在MacOS Big Sur 11.2.3上,Linux也有同样的问题。请看截图