You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since currently pyc compilation is implemented as a pass over the entire env, it can be quite costly:
λ uv pip install pypyp --compile
Resolved 1 package in 123ms
Downloaded 1 package in 68ms
Installed 1 package in 28ms
Bytecode compiled 58064 files in 53.81s
+ pypyp==1.2.0
In this venv, it's about 1000x longer than it takes to install without pyc compilation.
Note this very slow time is on macOS, it's much better on Linux machines I have access to (more like 10s). See #2326 (comment) for my laptop specs
To be clear, this is not a particularly pressing issue. The need to bytecode compile deltas is much lower than when building things from scratch. Nevertheless, ideally uv should be significantly faster than pip in all usage scenarios.
I'm not sure why this is... maybe something to do with checked hash validation that compileall doesn't handle correctly? The script predates Add an option to bytecode compile during installation #2086 , so maybe there's something else going on
(update: I've merged this change)
We could only bytecode compile the newly installed packages
If uv no longer forces recompilation, you could move the invalidation / mtime logic into Rust, not sure how much that would help, but could conceivably save you from shelling to compileall
Thanks for implementing #1788 , it's been great!
Since currently pyc compilation is implemented as a pass over the entire env, it can be quite costly:
In this venv, it's about 1000x longer than it takes to install without pyc compilation.
Note this very slow time is on macOS, it's much better on Linux machines I have access to (more like 10s). See #2326 (comment) for my laptop specs
To be clear, this is not a particularly pressing issue. The need to bytecode compile deltas is much lower than when building things from scratch. Nevertheless, ideally uv should be significantly faster than pip in all usage scenarios.
With that in mind, some possible suggestions:
It looks like uv currently forces recompilation
uv/crates/uv-installer/src/pip_compileall.py
Line 50 in 1181aa9
I'm not sure why this is... maybe something to do with checked hash validation that compileall doesn't handle correctly? The script predates Add an option to bytecode compile during installation #2086 , so maybe there's something else going on
(update: I've merged this change)
We could only bytecode compile the newly installed packages
If uv no longer forces recompilation, you could move the invalidation / mtime logic into Rust, not sure how much that would help, but could conceivably save you from shelling to compileall
Something something copy on write for pyc