Skip to content

Latest commit

Β 

History

History
84 lines (59 loc) Β· 3.32 KB

README.md

File metadata and controls

84 lines (59 loc) Β· 3.32 KB

msglc Β· load msgpack/cbor lazily, not all at once

codecov PyPI

Your data stays a valid msgpack/cbor blob. We just tack on a table of contents so you can jump straight to the piece you need β€” instead of decoding the whole file.


πŸ’₯ The problem

msgpack and cbor are compact and fast β€” until your file hits a few hundred MB and you only need one value buried inside.

Vanilla decoding forces you to read and decode everything, every time. That is wasteful after cold storage, it blows up memory, and it makes small reads feel huge.

✨ The fix

msglc appends a tiny table of contents to the payload, like a ZIP central directory. On open, only that index is read. The value you actually want is located and decoded directly β€” nothing more.

  • ⚑ Lazy & partial β€” pull one node from a multi-GB file.
  • 🧩 Still valid msgpack/cbor β€” drop the index and any compliant decoder reads it.
  • πŸ¦€ Rust backend β€” serialize at near-vanilla speed, or stream custom containers.
  • 🧬 Merge archives β€” combine files into one blob without decoding and re-encoding.
  • 🌍 Every filesystem β€” local, UPath, fsspec, and S3.

πŸš€ Quick start

from msglc import dump
from msglc.reader import LazyReader

dump("data.msg", {"a": [1, 2, 3], "b": {"c": 4, "d": 5, "e": [0x221548313] * 10}})

with LazyReader("data.msg") as reader:
    print(reader["b/c"])  # 4  ← only this node is decoded
    print(reader.read("b/d"))  # 5
    print(list(reader.keys()))  # ['a', 'b']

πŸ“¦ Install

pip install msglc

Snap on some extras for extra speed / features:

pip install "msglc[msgspec]"   # faster msgpack decoding
pip install "msglc[numpy]"     # numpy.ndarray support
pip install "msglc[s3fs]"      # S3 support
pip install "msglc[all]"       # everything above

πŸ—ΊοΈ Full documentation

Everything the README leaves out lives in the docs β€” cleanly split by concern:

Page What you'll find
Guide Serialization, deserialization, combining, streaming & custom codecs
Internals Why it's fast β€” the binary layout & TOC design
Configuration Every tunable option, its default & performance tips
Storage Local files, UPath, fsspec & S3
API reference The generated reference

✨ In one line: msglc = msgpack/cbor + a table of contents.

πŸ§‘β€πŸ’» Development

A working Rust toolchain is required. Install it via the official guide, then:

pip install -e ".[all]"

Not all optional dependencies are universally available β€” some are unavailable on platforms other than CPython.