Skip to content

check_overlapping_overloads is slow and often not needed #9691

Closed
@hauntsaninja

Description

@hauntsaninja

To Reproduce

With pure Python mypy:

~/dev/mypy master λ cat test.py   
import subprocess

~/dev/mypy master λ hyperfine -w 1 -M 5 'python -m mypy -m test --no-incremental'
Benchmark #1: python -m mypy -m test --no-incremental
  Time (mean ± σ):     10.316 s ±  0.955 s    [User: 9.301 s, System: 0.287 s]
  Range (min … max):    9.425 s … 11.452 s    5 runs

~/dev/mypy master λ vim mypy/checker.py
# change check_overlapping_overloads to early return

~/dev/mypy master λ hyperfine -w 1 -M 5 'python -m mypy -m test --no-incremental'
Benchmark #1: python -m mypy -m test --no-incremental
  Time (mean ± σ):      4.409 s ±  0.047 s    [User: 4.163 s, System: 0.191 s]
  Range (min … max):    4.346 s …  4.457 s    5 runs

The difference is substantial even for empty files. This would roughly halve the time it takes to run command line tests.

Proposal

As far as I can tell, check_overlapping_overloads does a lot of work to find problems which often don't get reported (and has no other side effects). Maybe we can just skip the call if self.msg.disable_count <= 0? But maybe this is a dangerous precedent to set.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions