• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aio-libs / multidict / 34052034344
87%

Build:
DEFAULT BRANCH: master
Ran 06 Sep 2026 06:33PM UTC
Jobs 1
Files 31
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

06 Sep 2026 06:32PM UTC coverage: 85.07% (-0.2%) from 85.267%
34052034344

push

github

web-flow
Add reversed() support to MultiDict views (C-ext + pure-Python) (#1340)

## What
Adds `__reversed__` to the keys, values, and items views of `MultiDict`,
`CIMultiDict`, and their proxies in **both** the C-extension and the
pure-Python implementation.

## Why
`dict` views have been reversible since Python 3.8; `multidict` views
supported forward iteration only. This brings parity for common use
cases (walking headers in reverse insertion order, popping the most
recently inserted occurrence) without forcing users to materialize a
list first.

Implements #448.

## How
- **C-extension** (`_multilib/hashtable.h`): added `md_init_pos_reverse`
and `md_prev`, mirroring `md_init_pos` / `md_next` (skipping `NULL`
identity slots left by deletions).
- **C-extension** (`_multilib/iter.h`): the iterator struct gained a
`reverse` flag; the existing per-kind `*_iter_iternext` functions
dispatch on it. Reverse iterators reuse the existing iterator
types/specs, so the existing `multidict_type_leak*` tests continue to
cover them.
- **C-extension** (`_multilib/views.h`): each view exposes
`__reversed__` (`METH_NOARGS`) returning a reverse-iterator instance.
- **Pure-Python** (`_multidict_py.py`): `HtKeys.iter_entries_reverse`
filters the entry array in reverse; each view class gained
`__reversed__` and a paired `_iter_reversed` that honors the version
guard.

## Testing
- New tests in `tests/test_multidict.py` cover read-only cases
(keys/values/items/empty/`__length_hint__`) parametrized over
`MultiDict`, `CIMultiDict`, both proxy variants, and both
implementations.
- New tests in `tests/test_mutable_multidict.py` cover skipping `NULL`
slots after `del`, and the `RuntimeError` raised when the dict is
mutated during iteration.
- Full suite: `1706 passed in 7.16s` (Python 3.12, C-ext + pure-Python).
- `pre-commit` (ruff, clang-format, mypy on 3.11 + 3.13): clean.

## Notes
This PR supersedes #1304 (which added pure-Python support only and was
waiting on a C implementation ... (continued)

634 of 1268 branches covered (50.0%)

Branch coverage included in aggregate %.

52 of 67 new or added lines in 3 files covered. (77.61%)

4215 of 4432 relevant lines covered (95.1%)

1.9 hits per line

Uncovered Changes

Lines Coverage ∆ File
9
90.63
-0.65% tests/test_multidict.py
6
98.89
-1.11% tests/test_mutable_multidict.py
Jobs
ID Job ID Ran Files Coverage
1 MyPy - 34052034344.1 06 Sep 2026 06:33PM UTC 62
85.08
GitHub Action Run
Source Files on build 34052034344
  • Tree
  • List 31
  • Changed 4
  • Source Changed 3
  • Coverage Changed 4
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #34052034344
  • d74a504c on github
  • Prev Build on master (#34048451564)
  • Next Build on master (#34056107527)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc