PyCQA / isort

A Python utility / library to sort imports.
https://pycqa.github.io/isort/
MIT License
6.49k stars 580 forks source link

Speed up exists_case_sensitive calls #2264

Open correctmost opened 5 months ago

correctmost commented 5 months ago

These changes save ~35ms when running isort on the yt-dlp codebase on Linux (~3.2secs -> 3.165secs, ~1% of the total time).

The savings should be a bit greater on Windows and macOS because repeated os.listdir calls are avoided too.

The main motivation behind these changes, however, was to speed up pylint, which relies on isort for import-order checks. When running pylint on a private codebase with ~2200 Python files, I see a reduction of ~10,000 stat calls after applying this PR.