Unimport's work (AST analysis and libcst refactoring) is CPU-bound, so files should be processed in parallel processes rather than with asyncio: asyncio only overlaps I/O waits, threads are limited by the GIL, and the analyzers keep per-file state on class attributes, which makes threads unsafe.
Proposed: a -j/--jobs N option (and jobs config key) that analyzes files in a process pool, keeping output, prompts and file writes in the main process in input order.
Unimport's work (AST analysis and libcst refactoring) is CPU-bound, so files should be processed in parallel processes rather than with asyncio: asyncio only overlaps I/O waits, threads are limited by the GIL, and the analyzers keep per-file state on class attributes, which makes threads unsafe.
Proposed: a
-j/--jobs Noption (andjobsconfig key) that analyzes files in a process pool, keeping output, prompts and file writes in the main process in input order.