parser: Accept bytes as input#51
Open
spbnick wants to merge 3 commits into
Open
Conversation
622641f to
6490f6f
Compare
b69f4ce to
e41d462
Compare
Contributor
Author
|
This has been updated to make |
e41d462 to
a10ecdd
Compare
Add an implementation of parse_json() function accepting either text or a text iterator and producing an iterable returning parsed values. Add a naive implementation of parse_json_file() function accepting a text file object and producing an iterable returning parsed values. This allows parsing JSON and JSON streams without passing them through a program.
Let Python give us the length of the "bytes" it already knows, instead of doing an strlen(). This improves performance a bit.
In addition to (Unicode) strings, also accept "bytes" (and corresponding iterators) as input to the parser. This allows skipping the decode/encode step when reading raw data from a file or socket, e.g. with os.read(). This introduces small, but measurable performance increase for such cases.
a10ecdd to
11a81a7
Compare
Contributor
Author
|
Closing this outdated PR for another attempt. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In addition to (Unicode) strings, also accept "bytes" (and corresponding iterators) as input to the parser. This allows skipping the decode/encode step when reading raw data from a file or socket, e.g. with
os.read(). This introduces small, but measurable performance increase for such cases.I'm not sure about this one. First about the interface, and then, surprisingly the benefits weren't that great and my (imperfect) testing sometimes showed performance decrease. However, my inner perfectionist says it's a good idea, so I'm posting it, just to get it off my back 😁. Don't hesitate to turn it down if you feel it's not beneficial.
This is based on and requires #49.