jq.py
jq.py copied to clipboard
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.
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 :grin:. Don't hesitate to turn it down if you feel it's not beneficial.
This is based on and requires #49.
This has been updated to make jq.parse_json()
accept either strings or bytes via the same arguments, instead of separate ones.
Closing this outdated PR for another attempt.