Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser: Accept bytes as input #51

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Commits on Feb 10, 2021

  1. Add parse_json() and parse_json_file()

    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.
    spbnick committed Feb 10, 2021
    Configuration menu
    Copy the full SHA
    6b8bf75 View commit details
    Browse the repository at this point in the history
  2. Use PyBytes_AsStringAndSize()

    Let Python give us the length of the "bytes" it already knows, instead
    of doing an strlen(). This improves performance a bit.
    spbnick committed Feb 10, 2021
    Configuration menu
    Copy the full SHA
    42f317e View commit details
    Browse the repository at this point in the history
  3. parser: Accept bytes as input

    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.
    spbnick committed Feb 10, 2021
    Configuration menu
    Copy the full SHA
    11a81a7 View commit details
    Browse the repository at this point in the history