#11759·pyright

Performance problems when using very large TypedDicts

Author: WizzerinusCreated Sep 14, 2026Updated Sep 17, 2026
Labelsbugaddressed in next version

Describe the bug Very large TypedDicts cause Pyright to be very slow. I've replaced **kw: object with **kw: Unpack[Dicts] where Dicts are various generated TypedDicts (the largest dict has 1442 parameters, but callers never set more than 20) in several parts of our codebase, and the time spent typechecking the project went up by 30%, from 37 to 48 seconds. Even worse, LSP is now hanging for several seconds when editing files that use classes referring to these large TypedDicts.

Deepseek found two performance bottlenecks when running such typechecking:

Code or Screenshots An example of a file that takes much longer to typecheck without the fixes is attached. On my machine the time to typecheck this went down from 3.3 seconds user time / 2.7 seconds CPU time, to 1.01 seconds / 0.7 seconds CPU time, which is a 70% improvement. This file is highly synthetic, so the gains are lower in most actual environments, but still. A version of this file with 2000 different fields takes over two minutes to typecheck, which is quite frankly absurd, and only 2 seconds with the fix.

hetero_500.py

VS Code extension or command-line

VSCode extension / CLI 1.1.412