| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Do not review until #156472 lands. |
Sorry, something went wrong.
|
#156472 has landed; this is rebased on it now. |
Sorry, something went wrong.
There was a problem hiding this comment.
183
Sorry, something went wrong.
File and readline tokenizers keep every byte they read because the lexer owns buffer growth and repairs its pointers after reallocations. Long inputs therefore grow tokenizer memory with the entire source. Let the reader reuse a bounded input window when no token or formatted string needs older bytes. Track the absolute offset of that window and save pointer offsets only when backing storage moves.
Tokenizer results expose pointers into the active input buffer. That ties every consumer to the buffer lifetime and prevents the reader from reusing older storage. Return logical source spans with their start and end locations instead. Pegen and `_tokenize` materialize a short-lived view before requesting another token, and the tokenizer no longer keeps a second end pointer for the last token.
…ython#156482) Represent token boundaries as logical source offsets with explicit start and end locations, and adapt pegen and _tokenize to consume them. Use SourceText to own decoded input across all reader modes. Streaming readers discard consumed windows while preserving logical offsets and reusing the allocation. Prepared and interactive input retain their source. Force source relocation on growth in debug builds and add coverage for formatted-string growth, interactive input, storage reuse, and offset limits. Scanner positions remain pointers, rebased when storage moves.
| Back | FazBrowse Home | New Git URL |
Return tokenizer tokens as logical source spans with start/end locations, and give all decoded input one owner in SourceText.
File and readline input discard consumed windows while advancing a logical base offset. Discard reuses the allocation and resets line metadata; prepared and interactive input retain their source. The separate streaming buffer allocation is removed. This prerequisite still rebases scanner pointers around append; #156654 replaces those pointers with offsets.
Debug source growth forces relocation. Tests cover f-/t-string growth in both token modes, interactive multiline input, discard/reuse, implicit-line metadata reset, and offset limits.
This follows #156472. The rest of the stack is #156484, then #156654.