Home
Because your floats deserve better than Base64.
zfp brings LLNL's battle-hardened ZFP compression library to Ruby. ZFP was built by national-lab scientists to compress petabytes of floating-point simulation data without losing the ability to do science on it. Now it's in a Ruby gem.
Whether you're cramming ten years of OHLCV market data into Redis, shipping a million embedding vectors over the wire, or just deeply offended by how wasteful Array#pack("E*") is — this gem is for you.
What ZFP Actually Does¶
ZFP compresses n-dimensional arrays of floats, doubles, int32s, and int64s — up to 4 dimensions — using a floating-point-aware transform that exploits spatial correlation across array elements. Unlike general-purpose compressors, it understands the structure of numeric data.
Compression Modes at a Glance¶
| Mode | What it does | Good for |
|---|---|---|
:reversible |
Bit-exact lossless | Audit trails, exact P&L, anything you'll diff |
:fixed_rate |
Guaranteed bits-per-value | Streaming, fixed-size storage slots |
:fixed_precision |
Guaranteed significant bits | Scientific reproducibility |
:fixed_accuracy |
Guaranteed absolute error bound | Financial data, ML embeddings, tolerance-bounded work |
Five-Second Example¶
require "zfp"
prices = [174.21, 174.85, 173.40, 175.10, 176.33] # ... 10,000 more
# Self-describing pack — no metadata bookkeeping required
packed = Zfp.pack(prices, type: :double, shape: [prices.size], mode: :reversible)
restored = Zfp.unpack(packed)
prices == restored # => true
Where to Go Next¶
- Installation — install
libzfpand add the gem - Quick Start — compress and decompress in five minutes
- Compression Modes — choose the right mode for your data
- Multi-Dimensional Arrays — 1-D through 4-D
- Numo::NArray — auto-detection and round-trip support
- API Reference — complete method documentation
- Examples — runnable scripts