Skip to content
Commit b37cd52f authored by Jeppe Fihl-Pearson's avatar Jeppe Fihl-Pearson
Browse files

Add LRU cache to RequirementsFinder._get_files_from_dir

This caches the result of the function for future invocations with the same
input, which can massively speed up future invocations if they have the same
input as previous calls.

In the case of this function this happens a lot, as it always is tried with all
parent paths in the file system from `isort` starting point.

The "backports.functools_lru_cache" package is used for Python 2 as it doesn't
have the built in `lru_cache` decorator which was added in Python 3.2.

Some benchmarks against a folder with 182 Python files with all finders enabled:

Python 2.7.15: Before 32 seconds, after 4 seconds.
Python 3.7.2: Before 28 seconds, after 2 seconds.
parent 70ac53cc
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment