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 in 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 replace your pickle calls with squashpickle ones.
squashpickle implements, dump, dumps, load, and loads functions.
To avoid confusion, it is recommended to dump and load to file with .gz extension eg: pkl.gz, but there is nothing enforcing this.
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 serializes 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.
Security
squashpickle uses Python's pickle and gzip modules internally. As with pickle and gzip, never load data from untrusted sources. Deserializing malicious pickle data can execute arbitrary code.
Metadata
Release files for squashpickle 0.2.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 | |
|---|---|---|---|---|
| squashpickle-0.2.0.tar.gz | 4.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| squashpickle-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.8 kB
Release files / squashpickle-0.2.0.tar.gz
| Download URL | squashpickle-0.2.0.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d05c2116bc9acbf5583c58c18460a5af9d61a811cdc9821408a544d3b0086011
|
|
BLAKE2b-256 checksum How to use checksums |
e903450ab4ea850229ab5ff9a728f70b24de467095f8bbe1bb331d74481eb601
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.20 {"installer":{"name":"uv","version":"0.11.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / squashpickle-0.2.0-py3-none-any.whl
| Download URL | squashpickle-0.2.0-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d6fd9f7830b0f0449bc3d4466bea373d8384838f16202560bd9694b016d44584
|
|
BLAKE2b-256 checksum How to use checksums |
7f65a710b03932d1e576e1b7974d57180cf291a1d3f4c74d57c689c42132cbf7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.20 {"installer":{"name":"uv","version":"0.11.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for squashpickle 0.2.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.