New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python3Packages.mypy: compile with mypyc #105462
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mypy includes mypyc, a compiler that translates annotated Python to C, which can be compiled into a Python module. When mypy is compiled with mypyc, it is about 4 times faster than the interpreted mypy, so using the compiled version is especially useful on large codebases where typechecking may take a long time. The wheels distributed on Pypi have included a mypyc-compiled mypy by default since version 0.700 [1]. [1]: http://mypy-lang.blogspot.com/2019/04/mypy-0700-released-up-to-4x-faster.html
To illustrate the advantage, here is the
And here for this PR:
|
Result of 2 packages marked as broken and skipped:
1 package blacklisted:
54 packages failed to build:
|
Result of 2 packages marked as broken and skipped:
2 packages failed to build:
43 packages built:
|
vcunat
added a commit
to vcunat/nixpkgs
that referenced
this pull request
Dec 30, 2020
Almost all i686-linux tests got blocked because of this problem: https://hydra.nixos.org/eval/1638038#tabs-now-fail It regressed in PR NixOS#105462 (commit ad26cb9). Now I tested that at least some test got fixed: nix build -f nixos/release-combined.nix nixos.tests.knot.i686-linux This change won't even cause any rebuild on 64-bit platforms, and using nix booleans seems nicer anyway.
10 tasks
FRidh
pushed a commit
that referenced
this pull request
Dec 30, 2020
Almost all i686-linux tests got blocked because of this problem: https://hydra.nixos.org/eval/1638038#tabs-now-fail It regressed in PR #105462 (commit ad26cb9). Now I tested that at least some test got fixed: nix build -f nixos/release-combined.nix nixos.tests.knot.i686-linux This change won't even cause any rebuild on 64-bit platforms, and using nix booleans seems nicer anyway.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation for this change
Mypy includes
mypyc
, a compiler that translates annotated Python to C, which can be compiled into a Python module. Whenmypy
itself is compiled withmypyc
, it is about 4 times faster than the interpretedmypy
, so using the compiled version is especially useful on large codebases where typechecking can take a long time.The wheels distributed on Pypi have included a mypyc-compiled mypy by default since version 0.700, but because those wheels are platform-specific, we can't take advantage of them. With this change, we build
mypy
withmypyc
from source, so it should work across all supported platforms.Ideally taking advantage of
mypyc
would be as simple as settingMYPY_USE_MYPYC=1
, but due to a few issues that have since been fixed upstream, this is not possible for v0.790. I expect that in a future version that will work, but for now, take the source from GitHub (because the package on Pypi is missing some files), and apply a few patches.Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)Running the bare
mypyc
binary fails with this message:But it also does that on master, so that is not a change introduced by this PR.
You can tell that
mypyc
did its work becauselib/python3.8/site-packages/mypy
is now full of.cpython-38-x86_64-linux-gnu.so
-files for every module. These are the compiled modules.