Latest Results
Speed up schema construction
Profiling Home-Assistant-representative schemas showed construction was
spending its time on framework plumbing, not validation work. Three
changes close the gap (construction went from ~1.5x slower than
voluptuous to ~1.3-1.6x faster, with the validation lead unchanged):
- Discover whether a schema uses Self during the compile walk instead of
a separate full pre-pass. _compile already recurses every mapping,
sequence, and key; only a combinator or wrapper (which compiles its own
branches) is opaque to it, so Self is detected on that branch node
alone. The Self-detection walk was the single largest construction
cost; this removes the duplicate traversal with no behavior change.
- Classify a mapping key's marker kind once in _make_candidate and reuse
the flags, rather than re-running overlapping isinstance checks per
attribute. A literal key (the common case) now does one isinstance, not
eight. Subtypes are still honored, so a custom marker subclass works.
- Build _MappingValidator's derived indexes in a single pass over the
candidates instead of six. The alias collision check needs the full
literal map, so it stays a small post-step (aliases are rare).
Adds compile benchmarks for the nested, leaf-heavy, combinator-heavy, and
deeply nested shapes (refactoring the existing NESTED/LEAF_HEAVY schemas
into fresh-each-call factories) so CodSpeed gates construction cost, not
just validation, going forward.frenck/faster-construction Latest Branches
+17%
frenck/faster-construction 0%
0%
© 2026 CodSpeed Technology