Users praise uv for shrinking lockfiles 40-50% via environment marker optimizations because the improvements make the Python ecosystem even better.
Based on 1 visible X reactions from 3 accounts; directional sample.
Ask a question below.
Published answers will appear here.
@charliermarsh Just when you think uv couldn't get any better. Thanks for fixing the Python ecosystem.
Say a package A is required by package B. If A should only be installed on Linux x86_64, we'd typically store a marker like `sys_platform == "linux" and platform_machine == "x86_64"`. But if B is itself only installed on Linux (`sys_platform == "linux"`), we can omit `sys_platform == "linux"` from A's marker, storing the delta (`platform_machine == "x86_64"`).
The first observation was: if you tell us that a lockfile only supports a subset of environments (like Linux), we can simplify all stored markers "assuming" that `sys_platform == "linux"`, which lets us remove that marker everywhere https://github.com/astral-sh/uv/pull/19933
We found a few optimizations that let us reduce the size of uv.lock files by "compressing" the environment markers. Some of our lockfiles are 40-50% smaller now. https://x.com/charliermarsh/status/2076781944529158202/photo/1
@charliermarsh Just when you think uv couldn't get any better. Thanks for fixing the Python ecosystem.
Say a package A is required by package B. If A should only be installed on Linux x86_64, we'd typically store a marker like `sys_platform == "linux" and platform_machine == "x86_64"`. But if B is itself only installed on Linux (`sys_platform == "linux"`), we can omit `sys_platform == "linux"` from A's marker, storing the delta (`platform_machine == "x86_64"`).
The first observation was: if you tell us that a lockfile only supports a subset of environments (like Linux), we can simplify all stored markers "assuming" that `sys_platform == "linux"`, which lets us remove that marker everywhere https://github.com/astral-sh/uv/pull/19933
We found a few optimizations that let us reduce the size of uv.lock files by "compressing" the environment markers. Some of our lockfiles are 40-50% smaller now. https://x.com/charliermarsh/status/2076781944529158202/photo/1
All of this is powered by a really cool library we use for marker algebra. We can perform ANDs, ORs, negations, complements, etc. on markers using binary decision diagrams.
The second: we store packages in the lockfile as a graph, so we can simplify each marker based on reachability. https://github.com/astral-sh/uv/pull/19971
Users praise uv for shrinking lockfiles 40-50% via environment marker optimizations because the improvements make the Python ecosystem even better.
Based on 1 visible X reactions from 3 accounts; directional sample.
Ask a question below.
Published answers will appear here.
The second: we store packages in the lockfile as a graph, so we can simplify each marker based on reachability. https://github.com/astral-sh/uv/pull/19971