microsoft / microsoft/vscode-python-debugger
Evaluating expression of large objects from the debug console is extremely slow
还没有人认领这个 Issue。
- 主要语言
- TypeScript
- 星标
- 181
- 派生
- 126
- 平均合并
- 2 天 3 小时
- 30 天内合并 PR
- 3
描述
I'm seeing an issue that apparently hasn't been reported yet. I have a fairly large dictionary in memory and when I want to get its length from the debug console it takes tens of seconds. Obviously, getting the repr of the dict takes that much time but I only want to get its length.
Code to reproduce:
from unittest import TestCase
from collections import defaultdict
import numpy as np
from types import SimpleNamespace
class MyTest(TestCase):
def test_large_defaultdict(self):
d = defaultdict(lambda: defaultdict(list))
for k in 'abcdef':
for l in 'ghijk':
for i in range(10000):
d[k][l].append(SimpleNamespace(
key = k,
cycle = np.arange(20),
value = np.zeros(20)
))
pass
Set breakpoint on pass and try to evaluate len(d) from the debug console after the breakpoint is hit. This warning is printed in the console:
pydevd warning: Computing repr of d (defaultdict) was slow (took 42.36s)
Customize report timeout by setting the `PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT` environment variable to a higher timeout (default is: 0.5s)
Yes, it is slow but why is repr called to print the number of items?
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 test.py 中的复现和调试控制台对 len(d) 的求值开始,然后跟踪调试器发出慢速 repr 警告的值解析路径。将 len(d) 的求值与直接检查对象进行比较,并确定在哪个位置不必要地计算了表示形式。完成标准是:大型对象的长度求值不再产生 repr 延迟,并且该行为由回归测试覆盖。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python, typescript, vscode
- 领域
- developer-experience, devtools
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100