@@ -1032,6 +1032,40 @@ beyond what incremental mode can offer, try running mypy in
10321032 Skip cache internal consistency checks based on mtime.
10331033
10341034
1035+ .. _parallel :
1036+
1037+ Parallel type-checking
1038+ **********************
1039+
1040+ By default, mypy checks all modules in the same Python process. This can be slow
1041+ for large code bases. Mypy offers experimental parallel type-checking mode using
1042+ multiple worker processes. In parallel mode, modules that do not depend om each
1043+ other are type-checked in parallel. :ref: `Incremental cache <incremental >` is
1044+ used to manage most of the shared state. Parallel type-checking also requires
1045+ :option: `--local-partial-types <mypy --no-local-partial-types> `, which is
1046+ enabled by default starting from mypy 2.0.
1047+
1048+ .. option :: -n NUMBER , --num-workers NUMBER
1049+
1050+ Use ``NUMBER `` parallel worker processes (in addition to the coordinator
1051+ process) to perform type-checking. Specifying ``--num-workers 0 `` (default)
1052+ disables parallel checking. Automatic detection of the optimal number
1053+ of workers is not supported yet.
1054+
1055+ Notes:
1056+
1057+ * An import cycle is always processed as a whole by a worker process. Thus,
1058+ avoiding large import cycles in your code will *significantly * improve
1059+ type-checking speed.
1060+
1061+ * Specifying a number of workers that is larger than the number of *physical *
1062+ CPU cores is not beneficial, since mypy is usually CPU bound. Best way to
1063+ tune the number of workers on a given machine is to start from 3-4 workers
1064+ and increase the number while you see a performance improvement.
1065+
1066+ * Parallel mode requires and automatically enables :option: `--native-parser `.
1067+
1068+
10351069Advanced options
10361070****************
10371071
@@ -1105,6 +1139,11 @@ in developing or debugging mypy internals.
11051139 cause mypy to type check the contents of ``temp.py `` instead of ``original.py ``,
11061140 but error messages will still reference ``original.py ``.
11071141
1142+ .. option :: --native-parser
1143+
1144+ This enables fast Rust-based parser that parses directly to mypy AST.
1145+ It will become the default parser in one of the next mypy releases.
1146+
11081147
11091148Report generation
11101149*****************
0 commit comments