yarl

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

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

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
92/100Excellent
Development Activity96
Maintenance96
Community76
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
83/100Excellent
Architecture85
Code Quality88
Innovation82
Learning Curve78

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

Devops · AI Development · Automation

42,074

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
Python100%
Updated yesterday
Python
100%
GPL 3.0

ComfyUI

AI Design Tools · AI Development

131,801

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
Python100%
Updated today
Python
67%
Apache 2.0

GPT Researcher

Productivity · AI Assistants

29,319

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
90
Repo Health
91
Technical
63
Dependency
Built with
Python67%
TypeScript20%
Updated 1 weeks ago
TypeScript
91%
Apache 2.0

Helicone

Monitoring · AI Development · Analytics

6,133

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
69
Repo Health
81
Technical
65
Dependency
Built with
TypeScript91%
Updated 1 weeks ago
Python
85%
Apache 2.0

knowhere

AI Development · Developer Tools

2,942

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

View details
83
Repo Health
75
Technical
69
Dependency
Built with
Python85%
HTML15%
Updated yesterday
Python
61%
Apache 2.0

marimo

Developer Tools · Data Engineering

22,670

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
90
Repo Health
91
Technical
65
Dependency
Built with
Python61%
TypeScript37%
Updated yesterday
Rust
63%
MIT

PostgresML

Databases · AI Development

6,819

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
Rust63%
JavaScript11%
Updated 1 years ago
Python
94%
Apache 2.0

SWIRL

Search · Databases · Data Engineering

3,043

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

View details
73
Repo Health
83
Technical
65
Dependency
Built with
Python94%
Updated 2 days 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

Search