multidict
multidict implementation
This package has a good security score with no known vulnerabilities.
Community Reviews
Solid, minimal-surface-area data structure with good security defaults
The library handles case-insensitive operations cleanly (CIMultiDict) which is critical for HTTP header handling, and it doesn't try to be clever about type coercion or validation—it stores what you give it. This means you control input validation at your application layer, which is the right design. Error messages are lean and don't leak implementation details. The immutable variants (MultiDictProxy) help prevent accidental mutations in security-sensitive contexts.
The C-accelerated version provides good performance without introducing unsafe memory operations that I've encountered. The codebase is mature, maintained by the aiohttp team, and has a solid CVE response history. No weird dependencies means minimal supply chain risk. It does what it says and nothing more.
Best for: HTTP header and query parameter handling where multiple values per key are needed and supply chain risk matters
Avoid if: You need complex validation logic or schema enforcement built into the data structure itself
Rock-solid foundation for HTTP header handling with excellent performance
The API is straightforward: CIMultiDict for case-insensitive operations (perfect for HTTP headers) and MultiDict for case-sensitive uses. The getall() method cleanly handles multiple values for the same key, avoiding the typical dict pitfalls. Immutability is built-in with proxy variants, which prevents accidental modifications in concurrent contexts. Error handling is predictable—KeyError on missing keys, no surprises.
The library has zero dependencies and doesn't try to do more than its job. No logging hooks because it doesn't need them—it's a data structure, not an I/O component. Thread-safe when used with immutable variants. Breaking changes between major versions have been minimal and well-documented. It just works, day after day, with no maintenance burden.
Best for: HTTP server/client implementations needing efficient multi-value header and query parameter handling with predictable memory characteristics.
Avoid if: You need a general-purpose ordered dictionary—stdlib's OrderedDict or dict (3.7+) is simpler for single-value mappings.
Solid multivalue dictionary implementation with some type hint limitations
The C-accelerated implementation delivers excellent performance, and the library integrates seamlessly with aiohttp and yarl. However, type hints are present but sometimes too generic - IDEs struggle to infer specific return types, leading to unnecessary type assertions. The documentation covers basics well but lacks comprehensive examples for edge cases like merging MultiDicts or handling encoding issues.
In daily use, it's reliable and the immutable variants (MultiDictProxy) are particularly useful for building safe APIs. Error messages are clear when type mismatches occur. The main friction point is remembering the distinction between getone() (raises KeyError) and get() (returns default) - this trips up newcomers but becomes second nature.
Best for: Projects handling HTTP protocols, web frameworks, or any scenario requiring multiple values per dictionary key with performance requirements.
Avoid if: You need rich type inference for complex generics or are building simple CRUD apps where standard dicts suffice.
Sign in to write a review
Sign In