Rajandran R Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Building Algo Platforms, Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in

UV: The Python Package Manager That’s 100x Faster Than Pip

4 min read

Why top Python developers are ditching pip and conda for UV – and you should too

What is UV and Why Should You Care?

UV is a blazingly fast Python package manager and project manager written in Rust. Created by Astral (the team behind Ruff), UV is designed to replace pip, pip-tools, pipx, poetry, pyenv, and virtualenv with a single, lightning-fast tool.

The Numbers Don’t Lie

  • 100x faster than pip for package installation
  • 10-100x faster than pip-tools for dependency resolution
  • Single binary – no Python installation required
  • Drop-in replacement for existing workflows

Why Switch from Traditional Methods?

The Pain Points You Know Too Well

Traditional Pip Workflow – Old Method But Still Very Slow

python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows
pip install -r requirements.txt  # ⏳ Grab coffee, this takes forever
pip freeze > requirements.txt    # Manual dependency management

Poetry Workflow – Better Dependency Management

poetry install  # ⏳ Still waiting…
poetry add package
poetry shell

The UV Revolution

With UV – Lightning fast, modern approach

uv sync          # ⚡ Installs everything in seconds
uv add fastapi   # ⚡ Adds and installs instantly
uv run app.py    # ⚡ Runs in isolated environment

Key Benefits

  1. Speed: 10-100x faster than traditional tools
  2. Simplicity: One tool replaces 6+ separate tools
  3. Reliability: Better dependency resolution
  4. Modern: Built for today’s Python development
  5. Cross-platform: Works identically on Windows, macOS, and Linux

Installing UV

Quick Installation

# macOS and Linux

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

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

Using pip (if you must)

pip install uv

Using Homebrew

brew install uv

Verify Installation

uv --version

Setting Up UV in an Existing Project

Scenario 1: Migrating from requirements.txt

# Navigate to your existing project
cd your-flask-project

# Initialize UV project
uv init --app

# Import existing requirements
uv add -r requirements.txt

# Your project now has pyproject.toml instead of requirements.txt

Scenario 2: Migrating from Poetry

# UV can read pyproject.toml directly
cd your-poetry-project

# Install dependencies
uv sync

# Add new dependencies
uv add requests

Scenario 3: Starting Fresh

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

# Add your typical stack
uv add fastapi uvicorn sqlalchemy

# Add dev dependencies
uv add --dev pytest black ruff

Essential UV Commands

Project Management

# Initialize new project
uv init my-project                 # Create new project
uv init my-project --app           # Create application project
uv init my-project --lib           # Create library project

# Sync dependencies (like pip install -r requirements.txt)
uv sync                            # Install all dependencies
uv sync --dev                      # Include development dependencies
uv sync --no-dev                   # Exclude development dependencies

Dependency Management

# Add packages
uv add fastapi                     # Add production dependency
uv add pytest --dev                # Add development dependency
uv add "django>=4.0,<5.0"          # Add with version constraints
uv add --optional extra package    # Add optional dependency

# Remove packages
uv remove package-name             # Remove dependency
uv remove package-name --dev       # Remove dev dependency

# Update packages
uv lock                            # Update lock file
uv sync --upgrade                  # Upgrade all packages

Running Code

# Run Python scripts
uv run script.py                  # Run script in project environment
uv run python -m module           # Run module
uv run --no-sync script.py        # Run without syncing dependencies

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

Python Version Management

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

# List Python versions
uv python list                   # List installed versions
uv python find 3.11              # Find specific version

# Set project Python version
uv python pin 3.11               # Pin project to Python 3.11

Virtual Environment Commands

# Create virtual environment
uv venv                          # Create .venv in current directory
uv venv my-env                   # Create named environment

# Activate environment (traditional way)
source .venv/bin/activate        # Unix/macOS
.venv\Scripts\activate           # Windows

# Or use uv run (recommended)
uv run python                    # Automatically uses project environment

Tool Management (replaces pipx)

# Install global tools
uv tool install ruff             # Install ruff globally
uv tool install black            # Install black globally

# Run tools without installing
uv tool run ruff check           # Run ruff without installing
uv tool run black .              # Run black without installing

# List installed tools
uv tool list                     # Show installed tools

Lock File Management

# Generate lock file
uv lock                          # Create/update uv.lock

# Install from lock file
uv sync                          # Install exact versions from lock

# Export to requirements.txt (for compatibility)
uv export --format requirements-txt --output-file requirements.txt

Real-World Flask/FastAPI Examples

Flask Project Setup

# Initialize Flask project
uv init flask-app --app
cd flask-app

# Add Flask stack
uv add flask flask-sqlalchemy python-dotenv

# Add dev dependencies
uv add --dev pytest flask-testing black ruff

Flask Application (app.py)

# Create basic app structure
from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
    return 'Hello from UV-powered Flask!'

if __name__ == '__main__':
    app.run(debug=True)

Run Flask App using UV

# Run the app
uv run python app.py

FastAPI Project Setup

# Initialize FastAPI project
uv init fastapi-app --app
cd fastapi-app

# Add FastAPI stack
uv add "fastapi[all]" sqlalchemy alembic python-dotenv

# Add dev dependencies
uv add --dev pytest httpx black ruff

# Run with uvicorn
uv run uvicorn main:app --reload

Adding Database Support

# SQLite with SQLAlchemy
uv add sqlalchemy

# PostgreSQL
uv add sqlalchemy psycopg2-binary

# With async support
uv add sqlalchemy[asyncio] aiosqlite

Pro Tips for Maximum Efficiency

1. Use pyproject.toml for Configuration

# pyproject.toml
[project]
name = "my-app"
version = "0.1.0"
dependencies = [
    "fastapi>=0.100.0",
    "uvicorn[standard]>=0.20.0",
]

[project.optional-dependencies]
dev = [
    "pytest>=7.0.0",
    "black>=23.0.0",
    "ruff>=0.1.0",
]

[tool.uv]
dev-dependencies = [
    "pytest>=7.0.0",
    "black>=23.0.0",
    "ruff>=0.1.0",
]

2. Create Useful Scripts

# Add to pyproject.toml
[project.scripts]
dev = "uvicorn main:app --reload"
test = "pytest"
lint = "ruff check ."
format = "black ."

Run with: uv run dev, uv run test, etc.

3. Use .uvlock for Reproducible Builds

  • Commit uv.lock to version control
  • Use uv sync in CI/CD for exact reproduction
  • Use uv export for Docker requirements.txt

4. Environment-Specific Dependencies

# Different environments
uv add --group prod gunicorn
uv add --group dev pytest black
uv add --group test coverage pytest-cov

# Install specific groups
uv sync --group prod
uv sync --group dev,test

Migration Checklist

From Pip + requirements.txt

  • Install UV
  • Run uv init in project directory
  • Run uv add -r requirements.txt
  • Test with uv sync and uv run
  • Update CI/CD to use uv sync
  • Delete old venv and requirements.txt

From Poetry

  • Install UV
  • Run uv sync (reads existing pyproject.toml)
  • Test dependencies with uv run
  • Update scripts to use uv run
  • Update CI/CD pipelines

From Conda

  • Export conda environment: conda env export > environment.yml
  • Install UV
  • Create new project: uv init
  • Manually add dependencies with uv add
  • Test thoroughly (some conda packages may need alternatives)

Performance Comparison

OperationPipPoetryUV
Install Django45s30s3s
Add new package15s12s1s
Resolve dependencies120s60s2s
Create environment30s25s1s

Benchmarks on M1 MacBook Pro with 50-package Django project

The Bottom Line

UV represents the future of Python package management. It’s not just faster – it’s fundamentally better designed for modern Python development. The combination of speed, simplicity, and reliability makes it a no-brainer upgrade for any Python developer.

Start Your UV Journey Today

  1. Install UV: curl -LsSf https://astral.sh/uv/install.sh | sh
  2. Try it on a small project: uv init test-project --app
  3. Migrate your main project: uv add -r requirements.txt
  4. Never look back at slow package management again

The Python ecosystem is evolving rapidly, and UV is leading the charge. Join the thousands of developers who have already made the switch and discovered what Python package management should have been all along.


Ready to supercharge your Python development? Install UV today and experience the difference that proper tooling makes.

Rajandran R Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Building Algo Platforms, Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in

Leave a Reply

Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More