Skip to main content
โšก Calmops

uv: The Ultra-Fast Python Package Manager Written in Rust

Introduction

Python developers have long struggled with slow package managers. Pip can take minutes to resolve and install dependencies. Enter uvโ€”a blazing-fast Python package manager written entirely in Rust. Created by the same team behind Ruff (the popular Python linter), uv can install packages 10-100x faster than pip, fundamentally changing how Python developers work.

With 7,000+ GitHub stars and adoption by major companies, uv is rapidly becoming the standard for fast Python package management.


What Is uv?

The Basic Concept

uv is an extremely fast Python package installer and resolver, written in Rust. It can replace pip, pip-tools, and virtualenv with a single, high-performance tool. It’s designed to be a drop-in replacement for pip while providing dramatic performance improvements.

Key Terms

  • Package Index: Repository of Python packages (PyPI is the default)
  • Resolution: The process of finding compatible package versions
  • Wheel: Pre-built Python package format
  • Virtual Environment: Isolated Python environment for projects
  • Lock File: Exact versions of all dependencies for reproducibility
  • PyPI: Python Package Index (pypi.org)

Why uv Matters in 2025-2026

Operation pip uv Speedup
Install package ~5s ~0.1s 50x
Resolve dependencies ~30s ~0.5s 60x
Create venv ~3s ~0.05s 60x
Uninstall package ~1s ~0.05s 20x

Installation

Quick Install

# macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

# Windows (PowerShell)
irm https://astral.sh/uv/install.ps1 | iex

# With pip
pip install uv

# With pipx (recommended)
pipx install uv

# With conda
conda install uv -c conda-forge

Verify Installation

uv --version
# uv 0.5.0

Basic Usage

Creating a Project

# Create new project
uv init my-project
cd my-project

# Or with a specific Python version
uv init --python 3.12 my-project

This creates:

my-project/
โ”œโ”€โ”€ main.py
โ”œโ”€โ”€ pyproject.toml
โ””โ”€โ”€ .python-version

Installing Packages

# Install a package (replaces pip install)
uv add requests
uv add "requests>=2.28"

# Add dev dependencies
uv add --dev pytest
uv add --dev "pytest>=7.0"

# Add group dependencies
uv add --group docs sphinx

# Sync all dependencies
uv sync

Using Virtual Environments

# Create and activate virtual environment
uv venv
source .venv/bin/activate  # Linux/macOS
.venv\Scripts\activate     # Windows

# Or use uv run (creates temp venv)
uv run python script.py
uv run --with pytest tests/

# Create with specific Python
uv venv --python 3.11

Advanced Features

Dependency Resolution

# Lock dependencies (create uv.lock)
uv lock

# Update lock file
uv lock --upgrade

# Sync to lock file
uv sync

Python Version Management

# Install Python versions
uv python install 3.12
uv python install 3.11 3.10

# List installed/cached Python
uv python list

# Run with specific Python
uv run --python 3.12 script.py

Workspace Projects

# Create workspace
uv init packages/my-package
cd packages/my-package

# Add to workspace in pyproject.toml
[tool.uv]
workspace = { members = ["packages/*"] }

Configuration

pyproject.toml

[project]
name = "my-project"
version = "0.1.0"
description = "My awesome project"
requires-python = ">=3.11"
dependencies = [
    "requests>=2.28",
    "fastapi>=0.100",
]

[project.optional-dependencies]
dev = [
    "pytest>=7.0",
    "ruff>=0.1",
]
docs = [
    "sphinx>=6.0",
]

[tool.uv]
dev-dependencies = [
    "pytest>=7.0",
]

[tool.uv.pip]
# Use pip compatibility mode
system = false

uv.toml

# Global configuration
# ~/.config/uv/uv.toml

# Cache directory
cache-dir = "~/.cache/uv"

# Use system Python
system = false

# Minimum Python version
python = "3.11"

# Index URL
index-url = "https://pypi.org/simple"

Migrating from pip

Common Commands

pip uv Description
pip install pkg uv add pkg Install package
pip install -r reqs.txt uv pip install -r reqs.txt Install from requirements
pip freeze > reqs.txt uv pip freeze > reqs.txt Export requirements
pip uninstall pkg uv remove pkg Uninstall package
pip list uv pip list List packages
venv venv uv venv Create venv
pip install -e . uv add -e . Editable install

Using uv with Docker

# Dockerfile
FROM python:3.12-slim

# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv

# Set working directory
WORKDIR /app

# Copy only dependency files
COPY pyproject.toml ./
COPY uv.lock ./

# Install dependencies
RUN uv sync --frozen --no-dev

# Copy source
COPY . .

# Run application
CMD ["uv", "run", "fastapi", "run", "app/main.py"]

Best Practices

1. Use Lock Files

# Always lock for reproducibility
uv lock

# Commit uv.lock to version control
git add uv.lock

2. Use uv run for Scripts

# Don't create venv for one-off scripts
uv run script.py
uv run --with pytest tests/

# With specific Python
uv run --python 3.12 script.py

3. Pin Dependencies

[project]
dependencies = [
    "requests>=2.28,<3.0",  # Pin range
    "pydantic==2.5.0",      # Pin exact
]

4. Use Workspaces for Monorepos

# pyproject.toml (root)
[tool.uv]
workspace = { members = ["packages/*"] }

[tool.uv.workspace]
members = []

Common Pitfalls

1. Forgetting to Sync

Wrong:

uv add requests  # Just adds to pyproject.toml
# Forgot to sync!
python -c "import requests"  # ImportError

Correct:

uv add requests
uv sync  # Install from pyproject.toml

2. Not Using Lock Files in CI

Wrong:

# CI script
uv sync  # Uses pyproject.toml, may get different versions

Correct:

uv sync --frozen  # Uses uv.lock exactly

3. Mixing pip and uv

Wrong:

pip install pkg  # Use pip
uv add pkg2      # Then uv

Correct:

# Stick to one package manager
uv add pkg
uv add pkg2

4. Wrong Python Version

Wrong:

uv run script.py  # Uses system Python
# Version mismatch errors!

Correct:

uv run --python 3.12 script.py
# Or set in pyproject.toml
requires-python = ">=3.11"

Performance Comparison

Benchmark Results

Operation pip uv Speedup
Install flask 4.2s 0.12s 35x
Install django 8.5s 0.18s 47x
Install numpy 12.3s 0.25s 49x
Install torch 45.2s 1.8s 25x
Resolve complex deps 28s 0.4s 70x

Why So Fast?

  1. Rust: Compiled language, no Python interpreter overhead
  2. Parallelism: Downloads and installs in parallel
  3. Efficient resolution: Rust-based resolver is much faster
  4. Caching: Aggressive caching of downloaded packages
  5. Less overhead: No need to create venvs for quick operations

External Resources

Official Documentation

GitHub & Community


Conclusion

uv represents a paradigm shift in Python package management. Its 10-100x speed improvement over pip isn’t just incrementalโ€”it’s transformative. Tasks that took minutes now take seconds, dramatically improving developer productivity.

Whether you’re a data scientist installing heavy dependencies, a web developer managing project requirements, or a DevOps engineer building Docker images, uv makes Python package management feel modern and fast.


Key Takeaways

  • uv is 10-100x faster than pip for all operations
  • Written in Rust for performance and safety
  • Drop-in replacement for pip, pip-tools, and virtualenv
  • Lock files ensure reproducible builds
  • uv run for one-off scripts without venv
  • Best practice: Use lock files in CI/CD

Next Steps: Explore Platform Engineering: Building Internal Developer Platforms to continue with DevOps trending topics.

Comments