Metadata-Version: 2.4
Name: triepack
Version: 1.3.1
Summary: Compressed trie dictionary format (.trp) — compact binary key-value storage with fast lookups and prefix search. Pure Python, no dependencies.
Author-email: "M. A. Chatterjee" <deftio@deftio.com>
License-Expression: BSD-2-Clause
Project-URL: Homepage, https://deftio.github.io/triepack/
Project-URL: Documentation, https://deftio.github.io/triepack/guide/api-reference/
Project-URL: Repository, https://github.com/deftio/triepack
Project-URL: Issues, https://github.com/deftio/triepack/issues
Project-URL: Changelog, https://github.com/deftio/triepack/blob/main/CHANGELOG.md
Keywords: trie,prefix-tree,dictionary,binary-format,serialization,compression,key-value,prefix-search,trp,triepack
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
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: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Archiving :: Compression
Classifier: Typing :: Typed
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Dynamic: license-file

# triepack

Compressed trie dictionary format (`.trp`) — compact binary key-value storage
with fast lookups and prefix search.

This is the native Python implementation: pure Python, no dependencies, no C
extension to build. It reads and writes the same bytes as the C reference
library and the JavaScript, Go, Rust, Swift, Java and Kotlin implementations.

## Install

```bash
pip install triepack
```

## Use

```python
from triepack import encode, decode

buf = encode({"hello": 42, "world": "foo"})
# buf is bytes holding the .trp binary

result = decode(buf)
print(result)  # {'hello': 42, 'world': 'foo'}
```

## Values

| Python            | `.trp` type        |
|-------------------|--------------------|
| `None`            | null               |
| `bool`            | bool               |
| `int >= 0`        | uint               |
| `int < 0`         | int                |
| `float`           | float64            |
| `str`             | string (UTF-8)     |
| `bytes`           | blob               |

Decoding also accepts float32 values written by other implementations,
widening them to a Python float. Python integers are arbitrary precision, so
the full 64-bit signed and unsigned ranges round-trip exactly.

## Format

Every buffer carries a 32-byte header, a bit-packed prefix trie, a typed value
store and a CRC-32. Keys are stored once per shared prefix, and symbols are
packed at the minimum width the key alphabet needs.

The encoder is deterministic: the same input produces the same bytes in every
implementation, which is checked by a
[shared conformance suite](https://github.com/deftio/triepack/tree/main/tests/conformance)
that all nine implementations run.

## Links

- [Documentation](https://deftio.github.io/triepack/)
- [API reference](https://deftio.github.io/triepack/guide/api-reference/)
- [Source and issues](https://github.com/deftio/triepack)
- [Changelog](https://github.com/deftio/triepack/blob/main/CHANGELOG.md)

## Development

```bash
cd bindings/python
pip install -e ".[test]"
python -m pytest
```

## License

Copyright (c) 2026 M. A. Chatterjee. BSD-2-Clause — see
[LICENSE.txt](LICENSE.txt).
