Visual Studio Code – Python – List Index Limit Max 300 – Debugger

Question:

I have a list contains several hundred entries. I think the total size of the list is 3.5 MB.

When debugging an issue I can’t seem to view any entry passed 300 and I see this message ‘Too large to show contents. Max items to show: 300’

Any ideas?

Enter image description here

Asked By: agleno

||

Answers:

You want to find a file named pydevd_resolver.py under your Visual Studio Code workspace directory
(you can find it with Bash this command: find / -name pydevd_resolver.py 2>/dev/null).

Open the file, and inside it look for a constant definition: MAX_ITEMS_TO_HANDLE = 300. You can change this number to whatever you like, but please note this will of course consume more resources, so be careful with this.

Just for the sake of completion, I paste the note provided above this definition in pydevd_resolver.py itself:

Note: 300 is already a lot to see in the outline (after that the user should really use the shell to get things) and this also means we’ll pass less information to the client side (which makes debugging faster).

Answered By: Adam.Er8

I would advise using the debug console to manually poke and prod your data versus trying to look at all of it at once if it’s that large and requires editing internal code to the debugger. The limit is there for a reason and so going past it could leave to issues.

Answered By: Brett Cannon

For the windows!

You can edit that file, pydevd_resolver.py, at:

USER_NAME.vscodeextensionsms-python.python-2021.3.680753044pythonFileslibpythondebugpy_vendoredpydevd_pydevd_bundle

It works for me.

Answered By: Quang Vu Tran

I attach VSCode to a running docker container, and I should edit the file at:

/root/.vscode-server/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_resolver.py

inside that docker container to make it work.

Answered By: keineahnung2345

Another option: you can edit the .vscode/launch.json file and add an environment variable to increase this number like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "env": {
                "PYDEVD_CONTAINER_RANDOM_ACCESS_MAX_ITEMS": "1000",
                ...
            },
            ...
        }
    ]
}
Answered By: Felipe Ferri
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.