npco
Pcodec-compressed numpy arrays — a drop-in replacement for numpy.save/numpy.load.
npco stores ndarrays in .npc files (single array) and .npcz files (multiple arrays) using pcodec compression. The API mirrors numpy's save/load/savez so you can start using it immediately.
Install
pip install npco
Quick start
import numpy as np
import npco
# Save a single array
arr = np.random.default_rng(0).standard_normal((1000, 100))
npco.save("data.npc", arr)
# Load it back
arr = npco.load("data.npc")
# Save multiple arrays
npco.savez("data.npcz", x=arr, labels=np.arange(1000))
# Load them back (lazy, dict-like)
with npco.load("data.npcz") as data:
print(data.files) # ['x', 'labels']
x = data["x"]
Compression options
Note: Compression levels greater than 8 often have limited effect on the compressed size but are significantly slower.
# Set compression level (0–12, higher = smaller + slower)
npco.save("data.npc", arr, compression_level=8)
# Or pass a full ChunkConfig for advanced control
from pcodec import ChunkConfig, DeltaSpec
npco.save(
"data.npc",
arr,
chunk_config=ChunkConfig(
compression_level=8,
delta_spec=DeltaSpec.try_consecutive(2),
),
)
Supported dtypes
float16, float32, float64, int8, int16, int32, int64, uint8, uint16, uint32, uint64.
Unsupported dtypes (complex, object, strings, …) raise TypeError.
API
| Function | Description |
|---|---|
npco.save(file, arr, *, compression_level=None, chunk_config=None) |
Save one array to .npc |
npco.load(file) |
Load from .npc → ndarray, or .npcz → NpczFile |
npco.savez(file, *args, compression_level=None, chunk_config=None, **kwds) |
Save multiple arrays to .npcz |
File format
.npc uses a numpy-style binary header (magic \x93NPCO\x00, dtype, shape, memory order) followed by pcodec standalone compressed data.
.npcz is a ZIP archive of .npc entries (no zip-level compression since pcodec already compresses the data).
Limitations
- No memory-mapping — pcodec requires full decompression
- No pickle / object arrays — only numeric dtypes above are supported
Acknowledgements
Made with the assistance of Claude Opus 4.6.
License
MIT License (see LICENSE file).
Metadata
Release files for npco 0.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 | |
|---|---|---|---|
| npco-0.1.0.tar.gz | 13.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| npco-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.4 kB
Release files / npco-0.1.0.tar.gz
| Download URL | npco-0.1.0.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cfaa494dbe4f92f54b622de70d6fdd5191edb243e4e7a61ca4c71aa19334d819
|
|
BLAKE2b-256 checksum How to use checksums |
31df5c7d38f7e38a9f0e2d80d3b5855863ce1d0902c5757a5d09a03ed9d1d3bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Apr 23, 2026.
Transparency logRelease files / npco-0.1.0-py3-none-any.whl
| Download URL | npco-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
159c7b8d535c7e8a0bf95c3306195240bebf0ca0a68a535289f7c7f7620e9a57
|
|
BLAKE2b-256 checksum How to use checksums |
975f5a2e60df78b9f0ae1471f69e9d84c8b23df1f3a868e47b8cb09eb9025ae4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Apr 23, 2026.
Transparency log