multidict

A fast dict-like multi-value mapping for HTTP headers and URL query strings, with a C-accelerated backend and a pure-Python fallback.

Library
PyPI
v6.7.1
493stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
78/100Good
Development Activity80
Maintenance68
Community84
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
83/100Excellent
Architecture80
Code Quality90
Innovation85
Learning Curve75

multidict is a dictionary-like data structure that allows multiple values per key while preserving insertion order — something Python’s built-in dict cannot do. It ships four concrete types: MultiDict and CIMultiDict for mutable use, and MultiDictProxy/CIMultiDictProxy as read-only dynamic views over an existing multidict. The CI-prefixed variants treat keys case-insensitively via a dedicated istr string subclass, matching exactly the behavior HTTP headers require.

Under the hood, multidict maintains two parallel implementations: a pure-Python reference implementation and an optional C extension that reimplements a CPython-style hash table to support duplicate keys efficiently, delivering roughly a 20-50x speedup over the Python fallback. Both implementations are validated against the same test suite to guarantee identical behavior, and the library underpins aiohttp and yarl, where it is exercised millions of times across the Python web ecosystem.

What You Get

  • MultiDict and CIMultiDict mutable multi-value dict types, plus MultiDictProxy/CIMultiDictProxy read-only dynamic views
  • A C-accelerated backend (enabled by default) with automatic fallback to a pure-Python implementation via MULTIDICT_NO_EXTENSIONS
  • istr, a case-insensitive string subclass powering the CI* variants for header-style lookups
  • Full collections.abc.Mapping/MutableMapping compatibility via structural Protocol-based ABCs so multidicts type-check and duck-type like ordinary dicts
  • Pickling, copying, and .pyi type stubs validated by a dedicated mypy test suite

Common Use Cases

  • Representing HTTP request/response headers, where the same header name can legitimately appear multiple times
  • Parsing and building URL query strings with repeated parameter names (?tag=a&tag=b)
  • Form data and multipart payloads where a field name can carry more than one value
  • Any application-level key/value store that needs case-insensitive lookups without losing duplicate entries

Under The Hood

Architecture multidict maintains two parallel implementations selected at import time by _compat.USE_EXTENSIONS: a pure-Python reference (_multidict_py.py) and an optional C extension (_multidict.c plus the _multilib/ headers — hashtable.h, htkeys.h, views.h, istr.h, iter.h, parser.h, state.h). Both backends implement the same four concrete classes and register against shared MultiMapping/MutableMultiMapping Protocol-based ABCs defined in _abc.py, so callers, isinstance() checks, and type checkers see one consistent interface regardless of which backend is active. Immutable proxies wrap a live reference to the underlying multidict rather than copying it, so proxy views reflect later mutations.

Tech Stack Pure-Python 3.10+ core with an optional CPython C extension, built via setuptools and distributed as prebuilt wheels across platforms using cibuildwheel (with uv as the build/test installer for speed). No runtime dependencies beyond a typing-extensions backport for Python < 3.11. Documentation is built with Sphinx and published to Read the Docs; the changelog is managed with towncrier.

Code Quality Testing is unusually thorough for a data-structure library: test_multidict.py, test_mutable_multidict.py, test_istr.py, test_abc.py, test_copy.py, test_pickle.py, and test_update.py exercise both backends through shared parametrized fixtures to guarantee behavioral parity, test_leaks.py specifically hunts for C-extension reference leaks, and test_mypy.py validates the .pyi type stubs against real usage. ruff enforces import sorting, a ban on mid-function imports, and pyupgrade rules repo-wide; coverage is tracked via Codecov, and CI (ci-cd.yml, reusable-linters.yml, codeql.yml) runs on every push, pull request, and a daily schedule.

API Design The public API mirrors dict deliberately — indexing, .get(), .items(), iteration, and dict-style construction all work unchanged, so only the multi-value-specific methods (add, getall, extend, popall, and friends) are new to learn. Case-insensitivity is opt-in via a parallel CIMultiDict/istr type rather than a runtime flag, keeping the common case simple. Every method in the Sphinx reference carries a doctested usage example, and pip install multidict gives a working C-accelerated build with zero configuration, with MULTIDICT_NO_EXTENSIONS=1 as an explicit escape hatch.

Used by 7 apps in this directory

Python
100%
Apache 2.0

Agno

Devops · AI Development · Automation

41,969

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

GPT Researcher

Productivity · AI Assistants

29,203

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
64
Dependency
Built with
Python67%
TypeScript20%
Updated 3 days ago
TypeScript
91%
Apache 2.0

Helicone

Monitoring · AI Development · Analytics

6,115

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
65
Repo Health
81
Technical
66
Dependency
Built with
TypeScript91%
Updated 4 days ago
Python
84%
Apache 2.0

knowhere

AI Development · Developer Tools

2,752

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
Python84%
HTML15%
Updated today
Python
61%
Apache 2.0

marimo

Developer Tools · Data Engineering

22,545

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
Python61%
TypeScript37%
Updated yesterday
Rust
63%
MIT

PostgresML

Databases · AI Development

6,821

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,042

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 5 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