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

beartype / plum / 33876858524
99%

Build:
DEFAULT BRANCH: master
Ran 04 Sep 2026 01:13PM UTC
Jobs 7
Files 16
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 Sep 2026 01:13PM UTC coverage: 99.335% (+0.002%) from 99.333%
33876858524

push

github

web-flow
perf(type): memoise the wrapper used by signature comparison (#301)

`Signature.__eq__` and `__le__` compare hints through `_type_hint_eq` /
`_type_hint_le`, each of which rebuilds `TypeHintWrapper(_substitute_any(h))`
from scratch. For a function no cache can serve -- one dispatching on
`Literal`, `list[int]`, `Callable[...]` -- full resolution runs on every call,
so those two helpers run about 14 times per call, and each time pay the
hashability probe, the `lru_cache` lookup for the rewrite, and `beartype`'s own
wrapper lookup.

The hints are fixed per signature, so memoise the finished wrapper instead of
the rewrite alone. Unhashable hints (`Annotated[int, {"a": 1}]`) fall back to
building it, as `_substitute_any` already does.

Uncached dispatch on a `Literal`, median of `tests/benchmarks`:

| path | before | after |
|---|---:|---:|
| `Literal` dispatch | 34,959 ns | 15,750 ns (2.22x) |
| registration (5 shapes) | 46.7-60.8 us | 43.5-57.3 us (~1.07x) |

Every cached path is unchanged: faithful dispatch 388 ns, `type[X]` 3,709 ns,
`invoke` 119 ns, annotated return 481 ns, all within noise of before.

This also repairs a regression. `Literal` dispatch cost 27.7 us before #296 and
35.7 us after it, flat across the sixteen commits in between -- the added
`_substitute_any` call in each comparison is the difference. The memo takes it
below the pre-#296 figure rather than merely back to it, because it also skips
the wrapper construction that was always there.

Like `_substitute_any`'s own cache, this one is not cleared by
`clear_all_cache`: both are keyed on an already-resolved hint, so
`type_mapping` and late-delivered `ModuleType`s are handled before this point.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>

10 of 10 new or added lines in 1 file covered. (100.0%)

1046 of 1053 relevant lines covered (99.34%)

6.73 hits per line

Jobs
ID Job ID Ran Files Coverage
1 run-3.11 - 33876858524.1 04 Sep 2026 01:14PM UTC 16
98.94
GitHub Action Run
2 run-3.13 - 33876858524.2 04 Sep 2026 01:14PM UTC 16
98.94
GitHub Action Run
3 run-3.12 - 33876858524.3 04 Sep 2026 01:13PM UTC 16
98.94
GitHub Action Run
4 run-3.14 - 33876858524.4 04 Sep 2026 01:13PM UTC 16
99.28
GitHub Action Run
5 run-3.14-pre-beartype - 33876858524.5 04 Sep 2026 01:13PM UTC 16
99.28
GitHub Action Run
6 run-3.10 - 33876858524.6 04 Sep 2026 01:14PM UTC 16
98.85
GitHub Action Run
7 run-3.13-pre-beartype - 33876858524.7 04 Sep 2026 01:14PM UTC 16
98.94
GitHub Action Run
Source Files on build 33876858524
  • Tree
  • List 16
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #33876858524
  • ca6c5bef on github
  • Prev Build on master (#33735604152)
  • Next Build on master (#34143372143)
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