Repository navigation
Highlights
✨ Parsing from streams
Every codec with parse (records, scalars and the combinators) now has parse_stream(read) and parse_stream_async(read), which parse one value from a file, a socket or an asyncio stream and leave the stream right after it. The value is parsed from the bytes read so far, starting with its minimum size, and exactly the missing bytes are read until it is complete, so nothing after the value is consumed. TruncatedDataError gains a needed attribute for this.
message = await Message.parse_stream_async(reader.readexactly)
header = Header.parse_stream(f.read)It is slower than reading the bytes by hand and calling parse, since a value with a variable part is parsed at least twice: 1.97 µs instead of 0.20 µs for a 6-byte header and a 16-byte body. See Streams for the rules and measurements.
Existing parsing is unchanged, both in API and in speed.
📚 Logo and social card
The documentation site and README have a project logo, and links to the site show a social card.
What's Changed
- 40359fe docs: Document that parse_stream is slower than parsing by hand (#5) (@doronz88)
- 1ae8b63 bytestruct: Make parse_stream a method of every codec with parse (#5) (@doronz88)
- 3980aa6 bytestruct: Parse values from streams (#5) (@doronz88)
- c469bdd docs: Add a social card and Open Graph tags (#4) (@doronz88)
- 8852b19 docs: Add a project logo (#3) (@doronz88)
Full Changelog: v0.1.2...v0.2.0