From: Richard Si <63936253+ichard26@users.noreply.github.com> Date: Thu, 4 Aug 2022 00:18:33 +0000 (-0400) Subject: Lazily import parallelized format modules X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/e269f44b25737360e0dc65379f889dfa931dc68a?hp=e269f44b25737360e0dc65379f889dfa931dc68a Lazily import parallelized format modules `black.reformat_many` depends on a lot of slow-to-import modules. When formatting simply a single file, the time paid to import those modules is totally wasted. So I moved `black.reformat_many` and its helpers to `black.concurrency` which is now *only* imported if there's more than one file to reformat. This way, running Black over a single file is snappier Here are the numbers before and after this patch running `python -m black --version`: - interpreted: 411 ms +- 9 ms -> 342 ms +- 7 ms: 1.20x faster - compiled: 365 ms +- 15 ms -> 304 ms +- 7 ms: 1.20x faster Co-authored-by: Fabio Zadrozny ---