Skip to content

v0.2.0

Latest

Choose a tag to compare

@doronz88 doronz88 released this 18 Oct 06:00
· 2 commits to master since this release
1ba30f4

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

Full Changelog: v0.1.2...v0.2.0