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

aio-libs / multidict / 37203143829
86%

Build:
DEFAULT BRANCH: master
Ran 04 Oct 2026 12:45PM UTC
Jobs 1
Files 49
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

04 Oct 2026 12:44PM UTC coverage: 86.01%. Remained the same
37203143829

push

github

web-flow
Share the bodies of the view set operators and compile them for size (#1669)

<!-- Thank you for your contribution! -->

## What do these changes do?

Rewrite the set operators and comparisons of the keys and items views in
the C extension around shared code. `views.h` goes from 1989 to 1283
lines:

- one dispatcher, `_view_binop()`, finds which operand is the view and
takes the critical section, in place of eight copies of that code and
twelve lock-only wrappers;
- `view & other` and `other & view` share one body per view, as do the
pairs that already ran the same loop (`items | other` with `other -
items`, `other | items` with `items - other`, and the four `&` / `-`
forms of the keys view);
- `_itemsview_has()` holds the "collect the matches, then compare
values" loop that was written six times;
- the six comparisons share one subset test instead of two loops and
recursion, and `^` is one function for both views.

The shared bodies are marked `COLD`. Without it the smaller unit moved
GCC's inlining budget and free-threaded builds lost 3% on `del d[key]`
and on items iteration, and 0.5% on `CIMultiDict(items)`. `COLD`
compiles the operators for size, which is where the slowdown below comes
from.

No behaviour change is intended. The one observable difference is that a
comparison calls `len(other)` once, not once per recursion step. The
pure-Python implementation is not affected.

Measured cost, instructions per operation under callgrind, `MultiDict`
with 100 keys against a 100-key operand (`CIMultiDict` is within a point
of each column):

| operation | keys GIL | keys FT | items GIL | items FT |
| --- | --- | --- | --- | --- |
| `v == o` | -0.9% | -0.7% | +3.5% | +3.8% |
| `v != o` | -2.9% | -2.1% | -1.3% | -1.0% |
| `v < o` | -0.9% | -0.7% | +3.7% | +4.0% |
| `v <= o` | -0.7% | -0.6% | +3.6% | +3.9% |
| `v > o` | -0.9% | -0.8% | +3.4% | +3.7% |
| `v >= o` | -0.7% | -0.5% | +3.6% | +3.9% |
| `v & o` | +9.5% | +6.0% | +7.3% | +2.8% |
| `set & v` | +16... (continued)

792 of 1584 branches covered (50.0%)

Branch coverage included in aggregate %.

9315 of 10167 relevant lines covered (91.62%)

1.83 hits per line

Jobs
ID Job ID Ran Files Coverage
1 MyPy - 37203143829.1 04 Oct 2026 12:45PM UTC 98
86.01
GitHub Action Run
Source Files on build 37203143829
  • Tree
  • List 49
  • Changed 2
  • Source Changed 0
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #37203143829
  • ae014a43 on github
  • Prev Build on master (#37199292436)
  • Next Build on master (#37203510052)
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