Two more micro-optimizations by ilevkivskyi · Pull Request #19627 · python/mypy
This has two things (totalling 1.5% locally, but see caveat below):
- Do not use
@contextmanger(that is relatively slow) forlocal_type_map, since it appears in multiple hot paths. - Do not show name suggestions for import errors in third party packages (since those errors are ignored anyway). It calls
difflibthat can be extremely slow with large modules.
Btw the second will probably not affect self-check, although it did affect my self-check, since apparently pytest depends on numpy. Well, they don't specify it as a package dependency, but https://github.com/pytest-dev/pytest/blob/main/src/_pytest/python_api.py#L17-L18
if TYPE_CHECKING: from numpy import ndarray
(and I have numpy installed in all my environments, LOL)