Metadata-Version: 2.4
Name: larzpack
Version: 0.1.0
Summary: Compact MessagePack-compatible binary serialization with canonical, deterministic output. Pure Python, zero dependencies.
Author: larz-scripter
License: MIT
Project-URL: Homepage, https://github.com/larz-scripter/larzpack
Project-URL: Repository, https://github.com/larz-scripter/larzpack
Project-URL: Documentation, https://github.com/larz-scripter/larzpack#readme
Project-URL: Issues, https://github.com/larz-scripter/larzpack/issues
Keywords: serialization,msgpack,messagepack,binary,canonical,deterministic,encoding,content-addressing,zero-dependency,pure-python
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# larzpack

**Compact, MessagePack-compatible, *deterministic* serialization. Zero dependencies.**

Encode Python data to compact binary — smaller than JSON, readable by any
MessagePack tool — with one property plain MessagePack doesn't guarantee: the
output is **canonical**. The same value always packs to the same bytes.

```python
from larzpack import packb, unpackb

packb({"b": 2, "a": 1}) == packb({"a": 1, "b": 2})    # True — key order irrelevant
unpackb(packb([1, "two", 3.0, {"x": True}]))          # round-trips
```

## Why the determinism matters

Integers use their smallest representation and map keys are emitted in sorted
byte order, so identical logical values produce **identical bytes**. That makes
the output safe to:

- **hash / sign** — a stable digest of a structure (pair with
  [larzcrypt](https://github.com/larz-scripter/larzcrypt));
- **content-address** — use the bytes (or their hash) as a key;
- **compare** — two structures are equal iff their packed bytes are equal.

Plain `json.dumps` and most MessagePack encoders don't promise this — key order
and integer widths can vary.

## Why else

- **Interoperable.** It's the real MessagePack wire format for the core types, so
  other languages and tools can read it.
- **Compact.** Binary, with fix-forms for small ints/strings/arrays/maps.
- **Zero dependencies.** Pure standard library.

## Install

```bash
pip install larzpack
```

## Usage

```python
from larzpack import packb, unpackb

blob = packb({"user": 42, "tags": ["a", "b"], "active": True, "score": 3.5})
unpackb(blob)     # {'user': 42, 'tags': ['a', 'b'], 'active': True, 'score': 3.5}
```

Supports `None`, `bool`, `int`, `float`, `str`, `bytes`, `list`, and `dict`.

## Tests

```bash
python -m unittest discover -s tests -v   # 22 tests incl. spec bytes + determinism
```

## The Larz stack

Pure-Python, zero-dependency building blocks: **[larz](https://github.com/larz-scripter/larz)** · **[larzchain](https://github.com/larz-scripter/larzchain)** · **[larzmoney](https://github.com/larz-scripter/larzmoney)** · **[larzcrypt](https://github.com/larz-scripter/larzcrypt)** · **[larzdb](https://github.com/larz-scripter/larzdb)** · **[larzagent](https://github.com/larz-scripter/larzagent)** · **[larzchart](https://github.com/larz-scripter/larzchart)** · **[larzmark](https://github.com/larz-scripter/larzmark)** · **[larztask](https://github.com/larz-scripter/larztask)** · **[larzvault](https://github.com/larz-scripter/larzvault)** · **[larzvm](https://github.com/larz-scripter/larzvm)** · **[larzcache](https://github.com/larz-scripter/larzcache)** · **[larzvalidate](https://github.com/larz-scripter/larzvalidate)** · **[larzid](https://github.com/larz-scripter/larzid)** · **[larzrpc](https://github.com/larz-scripter/larzrpc)** · **[larzstate](https://github.com/larz-scripter/larzstate)** · **[larzhttp](https://github.com/larz-scripter/larzhttp)** · **[larzconf](https://github.com/larz-scripter/larzconf)** · **[larzcron](https://github.com/larz-scripter/larzcron)** · **[larzlimit](https://github.com/larz-scripter/larzlimit)** · **[larzlog](https://github.com/larz-scripter/larzlog)** · **[larzcli](https://github.com/larz-scripter/larzcli)** · **[larzretry](https://github.com/larz-scripter/larzretry)** · **[larztime](https://github.com/larz-scripter/larztime)** · **[larzpdf](https://github.com/larz-scripter/larzpdf)** · **larzpack**

## License

MIT © larz-scripter
