-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Summary
uv has a --compile-bytecode option which precompiles the bytecode for packages across an entire venv. This results in slightly faster python startup time, but much slower package install time. compiling bytecode is deterministic depending on python version and python source file content. This should be eminently cacheable.
Example
This will be useful for local development where I install the same packages across many different venvs. I currently don't use --compile-bytecode because it's slow, but I would use it if the results were cached.
This also helps in github CI (I think). The astral-sh/setup-uv@v7 job caches the uv cache, not installed venvs. so you could save the --compile-bytecode cost on subsequent runs.
This wouldn't help docker builds, where you can save --compile-bytecode to its own layer. You get the same venv every time.