microsoft / microsoft/vscode-python-debugger
Evaluating expression of large objects from the debug console is extremely slow
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 181
- Forks
- 126
- Ø Merge
- 2 T. 3 Std.
- Gemergte PRs (30 T.)
- 3
Beschreibung
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?
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der Reproduktion in test.py und der Auswertung von len(d) in der Debug-Konsole. Verfolge anschließend den Pfad der Wertauflösung des Debuggers, der die Warnung über die langsame repr ausgibt. Vergleiche die Auswertung von len(d) mit der direkten Objektinspektion und ermittle, an welcher Stelle die Repräsentation unnötigerweise berechnet wird. Erledigt ist die Aufgabe, wenn die Auswertung der Länge großer Objekte nicht mehr durch die repr-Verzögerung beeinträchtigt wird und das Verhalten durch einen Regressionstest abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python, typescript, vscode
- Bereich
- developer-experience, devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100