microsoft / microsoft/vscode-python-debugger
Evaluating expression of large objects from the debug console is extremely slow
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 181
- Forks
- 126
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 3
Description
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the test.py reproduction and the debug console evaluation of len(d), then trace the debugger's value-resolution path that emits the slow repr warning. Compare evaluation of len(d) with direct object inspection and identify where representation is unnecessarily computed. Done means large-object length evaluation no longer incurs the repr delay and the behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, typescript, vscode
- Domain
- developer-experience, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100