namz (Python)
Lossless codec for NeuralAmpModeler .nam files.
A .nam is JSON whose bulk is one or more flat "weights" arrays written as ~20-character decimal
strings — which the NAM engine loads into float32 anyway. .namz stores each weight as a 4-byte
float32 instead: ≈5.5× smaller, bit-exact to what the engine computes, and deterministic
(no compression → byte-identical across runs, platforms, and languages). A small readable header exposes
tone/gear/device metadata without decoding the weights.
This package is a native Python port of the C++ reference and is byte-for-byte compatible with it and with every other port — it is validated against the shared conformance vectors (the cross-language TCK).
Install
pip install namz
Requires Python ≥ 3.9 and NumPy.
Library
import namz
nam = b'{"architecture":"WaveNet","weights":[0.5,-0.5,0.25]}'
blob = namz.pack(nam) # -> .namz bytes
assert namz.is_namz(blob)
assert namz.unpack(blob) == nam # lossless to float32
# Stamp a readable metadata header (typed: "true"/"false" -> bool, digits -> int, else string;
# a leading zero keeps it a string, so an identifier such as "0012345" survives intact):
opts = namz.PackOptions(metadata={"tone_type": "hi-gain", "boost": "true", "device": "tube:1,pnp:1"})
blob = namz.pack(nam, opts)
namz.read_meta(blob) # {'tone_type': 'hi-gain', 'boost': 'true', 'device': 'tube:1,pnp:1'} — no weight decode
API
| function | description |
|---|---|
pack(nam_json, options=None) -> bytes |
.nam JSON (str/bytes) → .namz. b"" on invalid JSON. |
unpack(data, max_json_bytes=256MiB) -> bytes |
.namz → .nam JSON. b"" on corruption / over-cap. Never raises. |
read_meta(data) -> dict[str, str] |
display header without touching weights. {} for v1 / non-.namz. |
is_namz(data) -> bool |
cheap magic check. |
PackOptions(shuffle=True, metadata={}) |
packing options. |
unpack is total: for any input bytes it returns bytes (empty on failure) and never raises.
CLI
namz encode in.nam out.namz [--no-shuffle] [--set key=value ...]
namz decode in.namz out.nam
namz map in.namz [--json] # print the metadata header (no weight decode)
namz verify in.nam # pack->unpack round-trip check + ratio
(Also available as python -m namz.)
Guarantees
- Lossless to float32 —
unpack(pack(x))is bit-exact at any nesting depth, including-0.0, subnormals, andFLT_MAX. - Deterministic —
pack(x)is byte-identical across runs and platforms; the codec is idempotent. - Robust — every malformed input (bad magic, unknown version/codec/dtype, truncation, trailing junk,
a lying
metaLen/numArrays, an over-cap body) is rejected cleanly.
Byte-match note
The skeleton is minified JSON with keys sorted ascending, matching the reference (nlohmann). It is validated byte-for-byte against the reference over the whole NAM domain (a large differential fuzz — config integers, simple decimals, non-ASCII, control chars, nesting). The weight payload itself is always exact float32, never text. Two documented edges, both outside the NAM domain:
- Non-finite weights (
NaN/±Inf) are out of contract and are rejected, exactly as the reference rejects them. - An integer literal outside
[int64_min, uint64_max]in a non-weight field is coerced to a double, as nlohmann does; this is byte-exact for double-representable magnitudes (e.g.2**64). For extreme 23+-digit integers nlohmann's own parser rounds imprecisely and may differ by one ULP — such values never occur in NAM config.
Development
pip install -e ".[test]"
pytest # runs the shared conformance vectors + property fuzz + adversarial suite
Versioned independently of the C++ reference; tracks wire format version 2.
License
MIT — see LICENSE. © 2026 Oleh Tsymaienko <oleh@darwinscat.com> & Alisa Lafoks <alisa@darwinscat.com> (Darwin's Cat).
Metadata
Release files for namz 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| namz-1.1.0.tar.gz | 27.9 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| namz-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.7 kB
Release files / namz-1.1.0.tar.gz
| Download URL | namz-1.1.0.tar.gz |
|---|---|
| Size | 27.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
adaa0100030bcc0006554b693011bf6e9b27952a3a39b073cd9bbdde0ac8406a
|
|
BLAKE2b-256 checksum How to use checksums |
1106c65676423a7cf1fdb944089a6c0210268205e27b8802e377e3db016a7ae0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.
Transparency logRelease files / namz-1.1.0-py3-none-any.whl
| Download URL | namz-1.1.0-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
60699a4e56322ed48ca4a12fe0b7fac63795d96c5add68b4fce28c6b2f46e1e5
|
|
BLAKE2b-256 checksum How to use checksums |
72fc8b3e894ab68cf5a9734aad31767df8163fa96369490a11a5a7b6b4de32d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.
Transparency logSecurity for namz 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for namz-1.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.