yarl

Immutable, encoding-aware URL class for Python, built for aiohttp and async network code

Library
PyPI
v1.25.1
1,497 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
92 /100 Excellent
Development Activity 96
Maintenance 96
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
83 /100 Excellent
Architecture 85
Code Quality 88
Innovation 82
Learning Curve 78

yarl provides a single URL class that parses, builds, and compares URLs while handling percent-encoding correctly and transparently. Every modification produces a new immutable URL object rather than mutating state in place, which makes it safe to pass URLs through concurrent and async code paths without defensive copying.

Originally built to back aiohttp’s client and server, yarl is now a standalone dependency used across the asyncio ecosystem wherever precise, spec-correct URL handling matters more than ad-hoc string splitting. A compiled Cython extension backs the hot paths, with a pure-Python fallback for PyPy and environments that can’t build C extensions.

What You Get

  • An immutable URL class where every mutation (/, %, .with_*()) returns a new object instead of changing the original
  • Decoded and raw (raw_*) accessors for every URL component: scheme, user, password, host, port, path, query, fragment
  • A MultiDictProxy-based query API so repeated query keys are handled correctly instead of silently collapsing
  • Automatic, spec-correct percent-encoding and decoding of non-ASCII and reserved characters
  • A compiled C/Cython extension for hot-path performance, with a pure-Python fallback (YARL_NO_EXTENSIONS) for PyPy or restricted environments
  • A human_repr() method that renders a URL back to its human-readable, non-encoded form

Common Use Cases

  • Building and normalizing outgoing request URLs inside an aiohttp client or any asyncio-based HTTP library
  • Safely joining base URLs with relative paths (url / 'foo' / 'bar') without manual string concatenation
  • Adding or replacing query parameters (url % {'bar': 'baz'}) while preserving correct encoding
  • Comparing, hashing, or using URLs as dict keys in caches and routers, relying on immutability for correctness
  • Parsing incoming request URLs on the server side to inspect path, query, and fragment components

Under The Hood

Architecture: The library centers on a single URL class in yarl/_url.py (~1,700 lines) that stores a parsed urllib.parse.SplitResult internally and derives every public property (scheme, host, port, path, query, fragment) from it lazily via propcache’s under_cached_property, so repeated attribute access after the first call is essentially free. Parsing and normalization logic is split into small focused modules — _parse.py for split/unsplit helpers, _path.py for path segment normalization, _query.py for query-string encode/decode, and _quoters.py/_quoting.py/_quoting_c.pyx for percent-encoding — keeping the core URL class readable while pushing performance-sensitive quoting into a compiled Cython module with a pure-Python (_quoting_py.py) fallback selected automatically at import time. Tech Stack: Pure Python 3 with an optional compiled Cython extension (_quoting_c.pyx) built via a custom in-tree PEP 517 backend (packaging/pep517_backend), and runtime dependencies on multidict (query storage as MultiDictProxy), propcache (cached properties), and idna (internationalized domain name encoding); the build can be forced to pure-Python via a pure-python config setting or the YARL_NO_EXTENSIONS env var for PyPy or systems without a C toolchain. Code Quality: The test suite is extensive and granular — 318+ test functions in test_url.py alone, plus dedicated files for caching, pickling, pydantic integration, path normalization, and dedicated benchmark suites (test_url_benchmarks.py, test_quoting_benchmarks.py) that guard performance regressions alongside correctness; the project ships py.typed for full type-checker support and enforces ruff linting across the main tree. API Design: The public surface reads close to natural URL syntax — url / 'foo' / 'bar' for path joins and url % {'bar': 'baz'} for query updates — while every component is exposed twice, once decoded (url.path) and once raw/encoded (url.raw_path), giving callers an explicit, unambiguous choice instead of a single lossy representation.

Used by 8 apps in this directory

Python
100%
Apache 2.0

Agno

AI Development · Automation · Devops

42,358

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
66
Dependency
Built with
Python 100%
Updated 5 days ago
Python
100%
GPL 3.0

ComfyUI

AI Design Tools · AI Development

135,247

The most powerful node-based AI workflow engine for creating images, video, 3D models, and audio with full control over every generation step.

View details
92
Repo Health
81
Technical
75
Dependency
Built with
Python 100%
Updated 6 days ago
Python
70%
Apache 2.0

GPT Researcher

AI Assistants · Productivity

29,650

The pioneering open-source autonomous AI agent that conducts deep, multi-source research and produces citation-backed reports exceeding 2,000 words — faster and more reliably than any human researcher.

View details
91
Repo Health
91
Technical
63
Dependency
Built with
Python 70%
TypeScript 18%
Updated 1 weeks ago
TypeScript
91%
Apache 2.0

Helicone

AI Development · Analytics · Monitoring

6,182

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

View details
70
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 91%
Updated 2 weeks ago
Python
86%
Apache 2.0

knowhere

AI Development · AI Memory · Developer Tools

3,541

Transform messy, unstructured documents into persistent, navigable memory that AI agents can actually use.

View details
82
Repo Health
75
Technical
66
Dependency
Built with
Python 86%
HTML 14%
Updated 1 weeks ago
Python
62%
Apache 2.0

marimo

Data Engineering · Developer Tools

22,918

A reactive Python notebook that eliminates hidden state, runs reproducibly, and deploys as a web app or script — stored as pure Python, built for the AI era.

View details
89
Repo Health
91
Technical
65
Dependency
Built with
Python 62%
TypeScript 37%
Updated 6 days ago
Rust
63%
MIT

PostgresML

AI Development · Databases

6,825

Run ML training and LLM inference natively inside PostgreSQL with GPU acceleration — no data movement required.

View details
51
Repo Health
76
Technical
64
Dependency
Built with
Rust 63%
JavaScript 11%
Updated 1 years ago
Python
94%
Apache 2.0

SWIRL

Data Engineering · Databases · Search

3,047

Federated AI search and RAG across 100+ enterprise sources—no data extraction, no vector database required.

View details
62
Repo Health
83
Technical
65
Dependency
Built with
Python 94%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers