Skip to main content

GZIP compressed pickle serialization.

Project description

Logo Squash Pickle

License PyPI - Python Version PyPI pre-commit.ci status GitHub Workflow Status

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

squashpickle-0.1.2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

squashpickle-0.1.2-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file squashpickle-0.1.2.tar.gz.

File metadata

  • Download URL: squashpickle-0.1.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.16

File hashes

Hashes for squashpickle-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a4b4596402a9e0ea367b2424cf7cef13cd5399e928be29c1bc2c8236cbe3156b
MD5 aeb51646c0115664a1f8e79aa36eafa2
BLAKE2b-256 56556d912ff42793739310f1cd7c729ea533d2b2d25f0d177fb42c6397b3b9c1

See more details on using hashes here.

File details

Details for the file squashpickle-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for squashpickle-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 560d4df2af438eab14315d602952f687df5d6d41fa6e3e461a8fcf2ca6b5d24b
MD5 a3ae0f189506ed458fa41803b34458be
BLAKE2b-256 c6a3e1939787d8670038fb798c3cfde598275888ff8a9779737088556f48a787

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page