microsoft / microsoft/vscode-python-debugger
Evaluating expression of large objects from the debug console is extremely slow
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 181
- Fork
- 126
- Merge medio
- 2g 3h
- PR unite (30g)
- 3
Descrizione
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?
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con la riproduzione in test.py e la valutazione di len(d) nella console di debug, quindi traccia il percorso di risoluzione dei valori del debugger che emette l'avviso relativo a repr lento. Confronta la valutazione di len(d) con l'ispezione diretta dell'oggetto e individua il punto in cui la rappresentazione viene calcolata inutilmente. Il lavoro è completato quando la valutazione della lunghezza di oggetti grandi non comporta più il ritardo di repr e il comportamento è coperto da un test di regressione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python, typescript, vscode
- Ambito
- developer-experience, devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100