> ## Documentation Index
> Fetch the complete documentation index at: https://fastapi2day.codewithsiva.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction to uv: Faster Python Package Management

> Learn what uv is, see a direct speed comparison with pip, understand why it's written in Rust, and install it on Windows, macOS, or Linux.

If you have been using pip and virtual environments for even a short while, you have probably noticed that installing packages can take a frustratingly long time. A project with a dozen dependencies might take a minute or more to set up from scratch. That friction adds up across a development day. `uv` solves this completely — not by a modest improvement, but by making package operations feel nearly instantaneous. Understanding why it is so much faster will also help you understand what the traditional toolchain was doing slowly.

## The speed difference in practice

Install the same package with both tools and time them:

```bash theme={null}
# Traditional pip
pip install pandas
# ⏱ Typically 15–30 seconds

# uv
uv add pandas
# ⚡ Typically 1–2 seconds
```

That is a 10–30x improvement for a single package. For a project with twenty dependencies, the difference compounds — what took 90 seconds with pip takes under 5 seconds with uv.

## A real-world comparison

Setting up a brand new project from scratch:

<Tabs>
  <Tab title="Traditional pip + venv">
    ```bash theme={null}
    # Step 1: Create virtual environment
    python -m venv .venv

    # Step 2: Activate it (command varies by OS and shell)
    # Windows PowerShell:
    .venv\Scripts\Activate.ps1
    # macOS / Linux:
    source .venv/bin/activate

    # Step 3: Install packages
    pip install requests pandas numpy

    # Step 4: Save dependencies
    pip freeze > requirements.txt
    ```

    **Time:** \~45–90 seconds\
    **Commands:** 4 (with OS-specific variations)\
    **Result:** No lock file, only a snapshot of currently installed versions
  </Tab>

  <Tab title="uv">
    ```bash theme={null}
    # Everything in two commands
    uv init my-project
    uv add requests pandas numpy
    ```

    **Time:** \~3–5 seconds\
    **Commands:** 2 (same on every OS)\
    **Result:** `pyproject.toml` with declared dependencies + `uv.lock` with exact reproducible versions
  </Tab>
</Tabs>

## Why is uv so fast?

### Written in Rust

Python tools are typically written in Python — which means they are interpreted at runtime. uv is written in **Rust**, a compiled systems programming language. The uv binary runs as native machine code, which is orders of magnitude faster for CPU-bound tasks like parsing dependency graphs.

### Parallel downloads

pip downloads packages sequentially — one at a time. uv downloads multiple packages simultaneously, saturating your network connection and dramatically reducing wall-clock installation time.

### Smart caching

When you install a package with uv, it stores the downloaded files in a global cache. The next time any project on your machine installs the same package version, uv copies from cache instead of downloading again. This makes repeated installs (very common in development) near-instant.

### Better dependency resolution

Calculating which exact package versions are compatible with each other is a computationally expensive problem. uv uses optimised algorithms that solve this faster than pip's resolver.

## More than speed: features that improve your workflow

### One tool instead of five

You no longer need to remember which tool handles which task:

```bash theme={null}
uv init          # Create a new project
uv add           # Install packages
uv remove        # Uninstall packages
uv sync          # Reproduce an environment from uv.lock
uv run           # Run a script in the project environment
uv python        # Manage Python versions
uv tool          # Install global CLI tools
```

### Automatic lock files

uv generates a `uv.lock` file that records the exact version of every package (including transitive dependencies). This guarantees that `uv sync` produces an identical environment on any machine. pip's `requirements.txt` captures installed versions after the fact — `uv.lock` is generated proactively and is always up to date.

### No manual venv activation

With `uv run python script.py`, uv automatically uses the project's virtual environment. You no longer need to remember to activate `.venv` before running code.

## Install uv

<Steps>
  <Step title="Run the installer for your platform">
    <CodeGroup>
      ```bash macOS / Linux theme={null}
      curl -LsSf https://astral.sh/uv/install.sh | sh
      ```

      ```powershell Windows theme={null}
      powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
      ```
    </CodeGroup>
  </Step>

  <Step title="Restart your terminal">
    Close and reopen your terminal (or VS Code) so the `uv` command is available on your PATH.
  </Step>

  <Step title="Verify the installation">
    ```bash theme={null}
    uv --version
    ```

    You should see a version number like `uv 0.4.x`.
  </Step>
</Steps>

<Note>
  uv updates itself. Run `uv self update` at any time to get the latest version.
</Note>

## Backwards compatibility

uv can work with existing pip-based projects. It reads `requirements.txt` and can install from it:

```bash theme={null}
uv pip install -r requirements.txt
```

You can adopt uv gradually — start using it for new projects while keeping existing projects on pip.

<Card title="Virtual Envs with uv" icon="code" href="/uv/virtual-env">
  Create your first uv project and manage virtual environments the modern way.
</Card>
