Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache find_module calls #2543

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

correctmost
Copy link
Contributor

Type of Changes

Type
🔨 Refactoring

Description

This PR speeds up the linting of codebases with lots of imports like yt-dlp.

Stats

Before

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
    63840    0.702    0.000    3.424    0.000 astroid/interpreter/_import/spec.py:129(find_module)
    38635    0.057    0.000    1.358    0.000 astroid/interpreter/_import/spec.py:287(find_module)
    38635    0.056    0.000    0.711    0.000 astroid/interpreter/_import/spec.py:224(find_module)
    38635    0.052    0.000    1.774    0.000 astroid/interpreter/_import/spec.py:263(find_module)
Command Mean [s] Min [s] Max [s] Relative
pylint --recursive=y . 32.063 ± 0.137 31.820 32.287 1.00

After

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
    18166    0.226    0.000    1.194    0.000 astroid/interpreter/_import/spec.py:129(find_module)
     6689    0.013    0.000    0.629    0.000 astroid/interpreter/_import/spec.py:225(find_module)
     6689    0.011    0.000    0.278    0.000 astroid/interpreter/_import/spec.py:290(find_module)
     6689    0.009    0.000    0.311    0.000 astroid/interpreter/_import/spec.py:265(find_module)
Command Mean [s] Min [s] Max [s] Relative
pylint --recursive=y . 30.058 ± 0.142 29.917 30.283 1.00

Copy link

codecov bot commented Sep 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.99%. Comparing base (71f5c0c) to head (28e13e9).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2543   +/-   ##
=======================================
  Coverage   92.98%   92.99%           
=======================================
  Files          93       93           
  Lines       11047    11056    +9     
=======================================
+ Hits        10272    10281    +9     
  Misses        775      775           
Flag Coverage Δ
linux 92.86% <100.00%> (+<0.01%) ⬆️
pypy 92.99% <100.00%> (+<0.01%) ⬆️
windows 92.97% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
astroid/interpreter/_import/spec.py 97.58% <100.00%> (+0.08%) ⬆️
astroid/manager.py 89.91% <100.00%> (+0.08%) ⬆️

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants