pypi / multidict
multidict
What changed in multidict 6 to 7, from its official release notes, upgrade guides and advisories. Sources checked 2026-12-05.
17 breaking7 security1 deprecations6 new APIs and options22 performance2 tooling24 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initmultidict 738 changes
Breaking changes 8
Creating a MultiDictProxy or CIMultiDictProxy with __new__() now requires the proxied multidict, matching the constructor and preventing a segmentation fault.
Support for Python 3.10 was dropped because it has reached end of life.
A str subclass's own lower() is no longer called to compute a key's case-insensitive identity; the identity comes from str.lower().
keys() and iteration yield each distinct key once, spelled as in its first item; items(), values(), and len(d) still include every item.
The build-time requirement is now setuptools >= 77.0 following the metadata and license metadata changes.
The C extension now raises TypeError when an argument is passed both positionally and by name, rather than silently misbehaving or ignoring surplus arguments.
The free-threaded build now requires CPython 3.14 or newer; older free-threaded interpreters fail with a clear compiler error, while GIL builds still support Python 3.10 and newer.
istr is final and can no longer be subclassed on either backend; code that subclassed it must wrap or convert instead.
Security 2
The pair is removed before result construction can run Python code that mutates the multidict, preventing a C-extension use-after-free and a pure-Python length miscount.
On Python 3.10 and 3.11, mutation during value-list allocation is refused with RuntimeError, avoiding a use-after-free.
Deprecations 1
Access emits DeprecationWarning, and the alias is removed from multidict.__all__; it is slated for removal in the next major release.
New APIs and options 4
A public C API lets third-party extensions create, read, and mutate multidicts without going through the Python-level API.
A cimport-able Cython API is available for third-party Cython modules to work with multidicts through the public API.
Provides the include path for the public C API header used by third-party extensions.
C extensions can register watchers to receive multi-value-aware notifications after a MultiDict or CIMultiDict change operation finishes.
Performance 13
Construction, update(), add(), assignment for new keys and setdefault() generally need fewer instructions or run faster; adding a new key needs about 0.5% more instructions on the GIL build.
Lookups, getall() on free-threaded builds without repeated keys, and key iteration became faster through reduced call overhead, lock avoidance and inlined lookup.
Replacing and removing items avoids redundant key identity work; deletion, assignment, pop(), duplicate-key replacement and free-threaded clear() became faster.
Mappings with exact istr keys use a compact table, taking each identity from the key's canonical form and cutting size by about 45%.
Mappings with exact str keys use a compact table without a separate identity or hash per entry; clear() allows compact storage to start again after another key requires the full layout.
Constructing a subclass of CIMultiDict got about 1% cheaper.
The C extension substantially speeds up operations keyed by plain str, including lookups, insertion, construction, extend(), and construction from a dict.
The C extension’s getall() is a little faster for keys with many values because collected values are no longer copied into a larger buffer as they accumulate.
Argument parsing in the C extension is faster for methods taking key, including their all-positional form and keyword arguments.
Constructing a subclass of MultiDict got about 1% cheaper.
The C extension improves lookup, insertion, deletion, iteration, and view-set performance; on free-threaded builds, concurrent mutations and lock-free reads are also faster.
Popping every item from a C-extension mapping now takes linear rather than quadratic time.
Key identity conversion and hashing now happen before the lock is taken, narrowing the critical section in free-threaded builds.
Fixes and other changes 10
A subclass that converts its argument in its own __init__() no longer raises TypeError before that initializer runs or starts with an empty multidict.
A huge length hint no longer raises MemoryError in extend(), update() or merge(); the C extension caps reserved room at the largest table the constructor allocates up front.
The C extension now takes case-sensitivity mode from the instance, so calling MultiDict.__init__ on a CIMultiDict does not make it case-sensitive, and CIMultiDict.__init__ accepts a MultiDict.
Fixed version values being truncated on Windows and 32-bit platforms, and a pure-Python race that could give concurrently mutated multidicts the same version.
Reinitializing a live multidict now installs its new contents and size before releasing old pairs, avoiding lost or leaked finalizer additions and incorrect length.
Python code that reads or mutates a multidict during initialization, updates, merges, deletion, popall, or related operations no longer causes crashes, lost or duplicated pairs, or backend disagreements.
The C extension now propagates MemoryError and KeyboardInterrupt raised by a positional argument's __len__ while estimating update size, matching the pure-Python backend.
Fixed a spurious RuntimeError when garbage collection mutated the multidict while getall() was building its result.
Fixed a data race on the free-threaded C extension by using relaxed atomic loads and stores for the multidict version counter.
Pure-Python MultiDict and CIMultiDict now convert canonical keys to exact str instances without invoking object.__str__() overrides, matching the C extension.
multidict 641 changes
Breaking changes 9
Calls that catch a list shrinking while it is being processed now raise RuntimeError, avoiding reads of freed memory on free-threaded builds.
Case-sensitive MultiDict no longer folds the case of istr keys and keeps them exactly as given.
In the pure-Python implementation, mutation before the first next call on an iterator now reliably raises RuntimeError, matching the C extension.
Support for free-threaded Python 3.13 has been dropped.
Extra keyword arguments are now rejected with TypeError instead of being silently ignored.
Iterator types now forbid direct instantiation, preventing a NULL internal pointer from being dereferenced by next().
Support for Python 3.9 has been dropped.
Extending a multidict with itself now doubles its contents; update(self) and merge(self) are no-ops.
Python 3.6 is no longer supported.
Security 5
Fixed freed-memory reads while iterating keys that are plain str, including when key conversion runs Python code or suspends a free-threaded critical section.
Fixed a free-threaded use-after-free when lock-free get, item lookup, or membership reads raced with a hash-table resize.
Multidict: Reference leak in CIMultiDict/MultiDict items-view union and subtraction
Multidict operations are protected against data races and memory-safety failures on free-threaded CPython; selected reads are lock-free on CPython 3.14+.
Repr of multidicts, proxies, and views is protected against free-threaded data races and infinite recursion on self-referential containers.
New APIs and options 2
Added a method returning a plain dict that groups every key’s values by key identity, unlike dict(md) or a comprehension over case-insensitive keys.
The keys, values, and items views of multidicts and their proxies now support reversed() in both implementations.
Performance 9
C-extension construction uses vectorcall to avoid creating intermediate positional-argument tuples and keyword-argument dictionaries in common cases.
Adding many values for the same key is faster; each added value no longer gets slower than the one before it.
Key identity comparison in the C extension uses a faster path, giving about 15% speed-up on benchmarks with many key comparisons.
The C implementation of getall is about 10% faster.
CIMultiDict.add() is 1.5 times faster through use of METH_FASTCALL.
get*() methods receive the same performance boost from METH_FASTCALL.
MultiDict.add() is 2.2 times faster through use of METH_FASTCALL.
pop*() methods receive the same performance boost from METH_FASTCALL.
setdefault() receives the same performance boost from METH_FASTCALL.
Tooling 2
Release-tag builds now publish wheels for iOS and Android on CPython 3.13+, so downstream users on those platforms no longer need a local compiler to install multidict.
Support has been added for building and shipping riscv64 wheels.
Fixes and other changes 14
Copying or re-initializing from another multidict now assigns a new version in the C extension, matching the pure Python implementation.
Fixed a free-threaded data race between lock-free reads and freeing a retired hash table.
Fixed free-threaded concurrent writes that could lose a key, and fixed setdefault inserting a duplicate instead of recognizing an in-flight key.
Deferred decrefs until mutations finish, fixing a standard C extension segmentation fault when a value finalizer releases the GIL during mutation.
Items-view set algebra no longer corrupts or hangs when a compared value’s equality method re-enters the same MultiDict.
The pure-Python implementation is safe for concurrent use under free-threaded builds, with per-instance locking and deadlock-safe locking for two-object operations.
Feature-detection fallbacks clear only expected TypeError and AttributeError exceptions; other exceptions, including MemoryError and KeyboardInterrupt, propagate.
Fixed a segmentation fault that could be triggered when getting an item.
Calling add with only one required argument supplied by keyword no longer causes a segmentation fault.
Multidict instances created via __new__ now start as a valid empty mapping, even if __init__ is not called.
Representations of multidicts, proxies, and keys/items views now remain valid Python string literals when keys contain quote characters.
Fixed a slow memory leak by decrementing the identity value before leaving md_pop_one on success.
Multidict[int] is supported by the pure-Python version.
Type annotations for keys of multidict mapping classes are fixed.