msglc
msglc serializes JSON compatible objects using msgpack or cbor and embeds a table of contents so that data can be loaded lazily and partially.
The encoded payload stays a valid msgpack/cbor blob.
The extra table of contents makes it possible to jump straight to the piece of data that is actually needed.
When to use it
It is a good fit for msgpack/cbor data of more than a few MB whenever one of the following holds.
- After cold storage, each retrieval only accesses part of the stored data.
- Decoding the whole file is too expensive in memory or time.
- Several encoded blobs need to be merged into one without decoding and re-encoding the payload.
Installation
msglc is published on PyPI.
Optional extras:
Note
The msgspec extra is optional but recommended.
When msgspec is installed it becomes the default msgpack codec; otherwise the pure Python msgpack codec is used.
Quick start
Serialize with dump, then read with LazyReader.
Only the requested node is decoded.
All data access must happen inside the with block because it is read from the file on demand.
Use to_obj to fully materialize a value before leaving the block.
Where to go next
- Guide — serialization, deserialization, combining archives, streaming and custom codecs.
- Internals — why it is fast, the binary layout and the table of contents design.
- Configuration — every tunable option and its default, plus performance advice.
- Storage — local files,
UPath,fsspecand S3. - API — the generated reference.