Skip to content

0.156.1: the depth check before a parse is linear in the text's length - #68

Merged
tmoosting merged 1 commit into
mainfrom
depth-scan-linear
Nov 27, 2026
Merged

tmoosting merged 1 commit into
mainfrom
depth-scan-linear

Conversation

@tmoosting

Copy link
Copy Markdown
Member

The depth scan that runs before every parse of a file this package did not write cut strings out with a regular expression that, on a string left open, retried from every quote to the end of the text. Its time grew with the square of the length: about a second for 16 KB of escaped quotes.

Now one pass over brackets, quotes and backslashes, as the npm SDK scans. Same answers: a test holds it to the old reading on 20,000 random texts, and a 40 KB text of that shape is timed (the old scan took 6.7 s on it; watched red with the old code planted, and the equivalence test watched red on a planted escape bug).

🤖 Generated with Claude Code

The scan cut strings out with a pattern that, on a string left open, retried from every quote to the end of the text: a 16 KB text of escaped quotes took about a second. It is now one pass over brackets, quotes and backslashes, held to the old answers on 20,000 random texts and timed on a 40 KB text of that shape (the old scan: 6.7 s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tmoosting
tmoosting merged commit a96dc1d into main Nov 27, 2026
11 checks passed

This branch was previously deployed

1 inactive deployment
pypi — a96dc1db Deployed Nov 27, 2026 by tmoosting via publish #249
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