一种加速调试和测试的方法。
debug-cache的Python项目详细描述
注意。这是alpha软件,小心使用。
旨在加快调试和测试过程的缓存。将中间结果存储在文件中。
安装
pip install debug-cache
用法
fromdebug_cacheimportDebugCachecache=DebugCache(path='/path/to/debug_cache')# or just use defaultfromdebug_cacheimportcache
第一个debug_cache用法是固定重复和繁重的调用,以收紧编辑/重新运行循环:
@cache.cacheddefsome_function(x,y):# do somethingreturnres
第二个debug_cache用法是检查函数结果是否没有更改。重构或优化时有用:
# Check that function results didn't change, they need to be cached first@cache.checkeddefsome_function(x,y):# ...# Same, but cache first time, check all subsequent ones@cache.checked(strict=False)defsome_function(x,y):# ...
如果函数结果与先前保存的结果不匹配,则将停止并启动调试器。如果未找到缓存结果,则严格版本也会停止。