POC: Use park_cursor to leave cursor at document end #31
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proof of concept to illustrate how to use
RustTokenizer
's proposedpark_cursor
method1 to avoid the "overconsumption" issue from #30 / smheidrich/py-json-stream-rs-tokenizer#47. Feel free to edit or open a new PR altogether with better ideas, this is really just to show how to use it.There is probably a more elegant solution that doesn't involve the introduction of the
level
param everywhere just to know when the top-level document ends, but I don't grok the code well enough come up with one. E.g. I initially thought it would be possible to just alterload
likewhich is similar to how you did it in the minimal example in smheidrich/py-json-stream-rs-tokenizer#47, but I guess that wouldn't work because people could no longer call e.g.
persistent
on the immediate result ofStreamJSONBase.factory
...In any case, this requires smheidrich/py-json-stream-rs-tokenizer#50 to be merged to actually work but I think it makes sense to only merge that once everything has been decided on on this end.
1 Still open to better names or turning it into a context manager
__exit__
if that makes sense.