uv: Modern python package manager

UV is a unified python packaging tool that is a replacement for tools like pip, poetry, pipx, pyenv, virtualenv, and more. This is what their documentation says. But why should you use or care about it if you are already using modern packaging tools like poetry. Checkout my previous articles on poetry. A lot of developers are now shifting to uv. Let’s dive into why uv is becoming a popular choice among developers.

The good news is that if you are already using requirements.txt file or pyproject.toml file, you can already start using uv.

First of all, uv is very fast. Lets compare how long a library like torch is installed using pip, poetry, and uv. For this experiment, I’ve used google colab to install torch separately using all three.

ToolCommandTime
pippip install torch1 min 35s
poetrypoetry add torch2 min 44s
uvuv pip install torch39s

Woah! I didn’t expect poetry to be slower than a whole minute. Let’s dig into why it is so. pip is faster than poetry because it uses legacy dependency resolver that is generally considered faster than custom dependency resolver used by poetry. On top of that, poetry's performance also suffers because on top of just installing package, it also maintains lock files, which is not a native feature for pip. Now hear me out! uv is faster. On top of that it also maintains lock files. This speedup can be attributed to uv being written in rust and it’s parallel downloads and resolution. If you are already using poetry, consider switching to uv just based on the speedup. But wait. Let’s look at what other features there are in uv

Managing python environments

It is very easy to manage python environment with uv. You can create a new environment with:

uv venv # creates a virtual environment in current directory named ./venv
uv venv myvenv # creates a named virtual environment
uv venv --python 3.14 # creates a virtual environment. Downloads the necessary python if required

Installing packages

If you are already installing packages using pip, it is easy to install packages using uv as well. Just add uv before pip for one off installs (does not modify the pyproject.toml or lock file). You can use it for experiments or one off installs.

To add a package as official dependency to your project, you may want to use uv pip add

uv pip install torch # wont update your dependencies in pyproject.toml or lockfile

uv pip add torch # updates pyproject.toml
uv pip lock # generate or update requirements.lock.txt

Installing your project

Once you have generated requirements.lock.txt file, you can use it in other projects without having to worry about the dependencies.

uv sync

So, if someone gives you a github link to their project that is compiled with uv lock. You can just clone them and perform uv sync and it should install.

uv is an amazingly fast tool that will help you build highly reproducible python application. This is specially a need when working with CI\CD.

I have not encountered any difficulty switching to uv from poetry. I will explore more and let you know in future blogs!

0
Subscribe to my newsletter

Read articles from Siddhi Kiran Bajracharya directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Siddhi Kiran Bajracharya
Siddhi Kiran Bajracharya

Hi there! I'm a machine learning, python guy. Reach out to me for collaboration and stuff! :D