GZIP compressed pickle serialization.
Project description
Squash Pickle
Like a pickle, only smaller*.
Tiny python package that compresses your pickles using gzip. Quacks like a pickle.
* For small objects (< 100 bytes) gzip overhead can end up increasing size. Only squash your pickles when you are working with big objects.
Getting Started
First install the package, this has no additional dependencies:
pip install squashpickle
Then simply replace your pickle calls with sqaushpickle ones.
squashpickle implements, dump, dumps, load, and loads functions.
Performance
The GZIP compression can have a HUGE impact on large objects. Say you are pickling something like a polars / pandas dataframe, these pickles may end up being hundreds of MBs. With squashpickle can get compression ratios exceeding 10x.
For example if we load a large dataframe of australian weather data.
Using pickle this object serialises to 37794198 bytes (~37.8MB).
Dumping the same dataframe with squashpickle results in 3370363 bytes (~3.4MB), around 9% of the overall file.
import polars as pl
import pickle
import squashpickle
df = pl.read_csv(r"C:\temp\weatherAUS.csv", null_values=["NA"])
print(len(pickle.dumps(df)), len(squashpickle.dumps(df)))
As with any compression, there is a performance cost to achieving the smaller files. For objects <1MB this is hardly noticeable, but for objects hundreds of MBs the delay can be significant. It'll depend on your use case if this is a worthwhile tradeoff.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file squashpickle-0.1.1.tar.gz.
File metadata
- Download URL: squashpickle-0.1.1.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32ccc65ad523da97b13af2ef69ae905b705ed4b73594385750a56f73e47073ba
|
|
| MD5 |
0ea3be7ccfd8a78b3b9096ea5d97c384
|
|
| BLAKE2b-256 |
28fb0d54bd5768ab0341240b53f780cbaac90a44fef6607d3958bce70c317546
|
File details
Details for the file squashpickle-0.1.1-py3-none-any.whl.
File metadata
- Download URL: squashpickle-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fdc708d2b150e4135deab386a89c25f49186a7d2c96c4885624316f231af0e97
|
|
| MD5 |
d2e281162e5e193a125aa8ea2febdad1
|
|
| BLAKE2b-256 |
9ee72143a7a118bb679cfdb999ae35eeb46d183ea8ea2f37f951916dcf0ee486
|