Skip to content

Perf#225

Merged
dimbleby merged 3 commits into
mainfrom
perf
Jul 19, 2026
Merged

Perf#225
dimbleby merged 3 commits into
mainfrom
perf

Conversation

@dimbleby

Copy link
Copy Markdown
Owner

No description provided.

dimbleby and others added 3 commits July 19, 2026 17:24
Several scanner/parser helpers re-asserted a precondition their sole
caller had already checked one frame up (e.g. _scan_basic_string
re-checking cursor-at-'"' after scan_string just asserted it). These
duplicate checks ran on every string, array, inline table, and header
parsed. Document the precondition in a docstring instead of
re-checking it, matching the codebase's existing convention that
helpers below a boundary trust their signatures.

No behaviour change; ~1.5-2.5% faster parsing measured via interleaved
A/B benchmarking against bench_pyproject.py.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6506e10c-587d-48ba-9ea3-632ef0edcbf6
Four related bugs in the "clone an existing attached Table into an
AoT" family, all found after adding a fuzzer op that appends an
already-attached Table rather than always synthesising a fresh dict:

* Cloning a plain `[k]` section as a new AoT entry kept the `[k]`
  header instead of rewriting it to `[[k]]` — `_clone_entry_slots`
  only remapped a header's `entry` discriminator when the *source*
  header already had one, so promoting a plain table to an entry
  silently left `entry` as None.

* `_owner_aot_entry is not None` was used in several places as a
  stand-in for "value is itself an AoT entry", but it's also true for
  anything physically nested inside one (inline tables, implicit
  sections, explicit nested sections). This crashed on inline tables
  (no header to clone) and silently double-nested explicit sections.
  Added `Container._is_own_aot_entry` to discriminate correctly.

* Cloning a dotted-key navigator view (e.g. the `a` in `t = {a.b=1}`)
  crashed because it owns no CST of its own to clone; it now
  synthesises fresh from its logical items like any other Mapping.

* Emptying an AoT reached only through dotted keys, itself nested
  inside another AoT entry, crashed on an over-strict assert in
  `_synthesise_header_then_insert_kv` that assumed a header could only
  be synthesised in this shape during `reposition_install`; entry
  removal reaches the same shape legitimately.

Each bug has a dedicated regression test in test_mutation.py, verified
to fail without its corresponding fix.

Also extends the mutation fuzzer (test_fuzz_mutation.py) with a
"clone_table" AoT op that appends an existing attached Table rather
than only ever synthesising fresh dict entries — this is what
surfaced all four bugs, and the existing tomli-vs-to_dict() oracle is
what actually catches them (the idempotence oracle alone would not,
since the buggy output is a stable self-consistent fixed point).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ac201ee3-8e8a-44ca-9d3a-001f6fdb4308
@dimbleby
dimbleby merged commit 1a62cf3 into main Jul 19, 2026
11 checks passed
@dimbleby
dimbleby deleted the perf branch July 19, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant