UV is a revolutionary tool for managing Python dependencies and environments, written in Rust. Thanks to optimizations and a modern architecture, it outperforms traditional solutions like pip or Poetry. Check out how it works, why it is so fast, and how to get started with it.
What is UV and why should you be interested in it?
UV is a modern package manager and project management tool for Python, created by Astral – the developers of the popular linter ruff. Its main goal is to replace several tools at once: pip, venv, pip-tools, and even partially poetry or pdm. Thanks to its architecture written in Rust, UV offers performance unattainable for traditional Python-based solutions.
Key features of UV include:
- Ultra-fast package installation and updates.
- Built-in virtual environment management.
- Dependency locking (generating the
uv.lockfile). - Compatibility with
pyproject.tomlandrequirements.txt. - Ability to run scripts without global package installation (similar to
pipx).
UV is not just another experiment – it is a project developed by an experienced team that has already proven its effectiveness with tools like ruff. It is worth paying attention to if you are looking for a more efficient alternative to pip or poetry.
Who is behind the UV project and how has it evolved?
UV was created by Astral, founded by Charlie Marsh and Greg Price. Astral had already made a name for itself with tools such as:
ruff– a lightning-fast Python linter that gained massive popularity.rye– an experimental package manager that pioneered the idea of unifying Python tools.
The first public version of UV (0.1.0) was released on February 14, 2024. Since then, the project has been developing dynamically, with regular updates every 1-2 weeks. Rapid development and community engagement have led to UV gaining over 15,000 stars on GitHub in just a few months.
The main motivation for creating UV was the frustration associated with the slow performance of traditional tools. pip or poetry are written in Python, which comes with performance limitations, especially when resolving dependencies or performing I/O operations. UV solves these problems by leveraging the capabilities of the Rust language.
Why is UV so fast? Architecture and optimizations
UV outperforms the competition in terms of performance, and the key to its speed lies in several crucial aspects:
1. The Rust language and low-level control
UV is written in Rust, which gives it several significant advantages over Python-based tools:
- No interpreter overhead: Python, despite its flexibility, is slower than compiled languages like Rust. UV avoids this problem by running as a native binary.
- Multithreading: Rust allows for the effective use of multiple CPU cores, which speeds up operations like dependency resolution or package installation.
- Memory control: Rust eliminates garbage collection issues, which translates into more stable and faster operation.
For example, installing the numpy package with UV takes about 0.5 seconds, while in pip it takes 5-10 seconds. That is a 10-20x difference!
2. Modern dependency solver
UV uses the pubgrub algorithm, which is also used in poetry. However, unlike poetry, UV has optimized this algorithm for performance. As a result, dependency resolution is not only accurate but also lightning-fast.
3. I/O optimizations and caching
UV minimizes disk read/write operations, which are one of the main bottlenecks in Python tools. It achieves this through:
- Global cache: Downloaded packages are stored in a central location, which speeds up subsequent installations.
- Avoiding redundant file reads: UV reads configuration files (e.g.,
pyproject.toml) only once, whereas tools likepipmight do so multiple times. - Built-in package index server: UV uses a local proxy to PyPI, which reduces network latency.
4. Benchmarks – UV vs. the competition
The table below presents a comparison of execution times for key operations in UV and other tools (based on Astral benchmarks from March 2024):
| Tool | Install numpy |
Install 100 packages | Create virtual environment |
|---|---|---|---|
| UV | 0.5s | ~5s | ~0.1s |
| pip | 5-10s | 60-120s | 2-5s |
| poetry | 8-15s | 90-180s | 3-8s |
| pdm | 6-12s | 70-150s | 2-6s |
It is worth noting that results may vary depending on the system and configuration, but the trend is clear: UV is significantly faster than the competition.
Advantages of UV – why should you use it?
UV not only beats the competition in performance but also offers a range of other benefits:
1. One tool for everything
UV combines the functions of several tools into one:
pip– package installation.venv/virtualenv– virtual environment management.pip-tools– generatingrequirements.txtfiles.pipx– running scripts without global installation.
Thanks to this, you no longer need to remember multiple commands or tools – UV does it for you.
2. Compatibility with existing projects
UV is compatible with:
pyproject.tomlfiles (the standard in modern Python projects).requirements.txtfiles (legacy, but still widely used).uv.lockfiles (equivalent topoetry.lockorpdm.lock).
This means you can seamlessly integrate UV into existing projects, regardless of which tool you used previously.
3. Minimal requirements and easy installation
UV is provided as a statically compiled binary, which means that:
- It does not require Python to be installed to run (though the Python project itself obviously does).
- It has no dependencies on other packages.
- It runs on Linux, macOS, and Windows (including WSL2).
Installing UV takes literally a few seconds – just run one command.
4. Active community and regular updates
UV is being developed very actively. On average, a new version appears every 1-2 weeks, and the Astral team responds quickly to bug reports and user suggestions. The project already has over 15,000 stars on GitHub, which proves the high level of community interest.
5. Support for multiple Python versions
UV works with Python version 3.7 and newer. This means you can use it in both new and older projects.
How to install UV?
Installing UV is simple and does not require special preparations. Below you will find instructions for various operating systems.
System requirements
- Operating systems: Linux, macOS, Windows (WSL2 recommended for Windows).
- Python: Version 3.7 or newer (required for running Python projects, but not for installing UV itself).
- Dependencies: None – UV is a self-contained binary.
Installation methods
The simplest way to install UV is to use the installation script:
curl -LsSf https://astral.sh/uv/install.sh | sh
Alternatively, you can install UV via pip (though this is not recommended, as UV does not require Python):
pip install uv
If you prefer manual installation, you can download the binary from the GitHub releases page and place it in a directory included in your PATH.
Installation verification
After installation, check if UV is working correctly:
uv --version
You should see the version number, e.g.: uv 0.1.15 (2024-04-05).
How to use UV? Basic commands
UV offers many useful commands that replace the functions of traditional tools. Below are the most important ones.
1. Creating a new project
To create a new project, use the uv init command:
uv init my_project
cd my_project
UV will create a project structure with a pyproject.toml file, which will contain the basic configuration.
2. Installing packages
UV allows you to install packages in several ways:
- Installing a single package:
uv add requests
- Installing a package in a specific version:
uv add numpy@1.24.0
- Installing packages from a
requirements.txtfile:
uv pip install -r requirements.txt
3. Managing virtual environments
UV has built-in support for virtual environments:
- Creating a virtual environment:
uv venv
By default, the environment will be created in the .venv directory.
- Activating the environment:
# Linux/macOS
source .venv/bin/activate
# Windows
.venv\Scripts\activate
4. Running scripts
UV allows you to run Python scripts without needing to install packages globally:
uv run python my_script.py
You can also launch a REPL with installed packages:
uv run python
5. Locking dependencies
To generate a uv.lock file with exact package versions, use:
uv lock
The uv.lock file works similarly to poetry.lock or pdm.lock and ensures installation reproducibility.
6. Updating packages
To update a package to the latest version, use:
uv update requests
UV development roadmap – what's next?
UV is a project that is developing dynamically, and the Astral team has ambitious plans for the future. Here is what we can expect in the coming months:
1. Support for alternative package indexes
In the second half of 2024, UV is expected to gain support for private package repositories, which will facilitate work in corporate environments.
2. Integration with build tools
UV is set to be integrated with popular Python project build tools, such as setuptools or hatch. This will make it an even more universal solution.
3. Experimental support for Python 3.13
The Astral team plans to add support for the latest Python version, allowing UV to be used in cutting-edge projects.
4. Expanding locking features
The uv.lock file is to be expanded with additional metadata, which will further increase installation reproducibility.
Will UV replace pip and Poetry?
UV has the potential to become the primary tool for managing Python projects, but this does not mean it will immediately replace pip or poetry. Here are a few reasons why UV might gain popularity:
- Performance: UV is simply significantly faster than the competition, which is crucial in large projects.
- One tool for everything: UV combines the functions of several tools, simplifying the workflow.
- Active community: The project is being developed very dynamically, which ensures it will continue to evolve in the future.
However, pip and poetry still have their advantages:
pipis the standard and is pre-installed in most Python distributions.poetryoffers more extensive project management features, such as publishing packages to PyPI.
UV is a great alternative, but will it replace pip or poetry? That depends on user needs. If you value performance and simplicity, UV might be the ideal choice.
Summary – is it worth trying UV?
UV is one of the most promising tools for managing Python projects to appear in recent years. Its main advantages are:
- Ultra-fast installation and package management thanks to its Rust-based architecture.
- One tool for everything – replaces
pip,venv,pip-tools, and partiallypoetry. - Easy installation and minimal requirements – runs on Linux, macOS, and Windows.
- Active community and regular updates – the project is developing dynamically.
If you are looking for a more efficient alternative to pip or poetry, UV is definitely worth trying. Its speed and simplicity can significantly improve your workflow, especially in larger projects.
It is also worth following the project's development, as the Astral team has ambitious plans for the future. UV could become the standard for Python project management, just as ruff became the standard for linting.
If you want to learn more about performance optimization in development tools, check out our post on limiting CPU and RAM usage by processes on Linux. And if you are interested in how Rust is revolutionizing system tools, read about Rust Coreutils on Windows.
Sources
- https://docs.astral.sh/uv/
- https://github.com/astral-sh/uv
- https://github.com/astral-sh/uv#features
- https://github.com/astral-sh/uv/releases
- https://www.youtube.com/watch?v=
- https://github.com/astral-sh/uv#benchmarks
- https://astral.sh/blog/uv
- https://github.com/astral-sh/uv#comparison-to-other-tools
- https://astral.sh/uv/install.sh
- https://docs.astral.sh/uv/getting-started/installation/
- https://docs.astral.sh/uv/guides/
- https://github.com/astral-sh/uv/discussions
Comments