Skip to main content

Calculates the pickled size of an object

Project description

Sometimes it is handy to know how much space an object will need when it will be serialized with pickle without actually pickling it. Especially when the object is large, pickling can be slow and memory consuming.

This library can calculate the exact space requirement without actually pickling it. It still has to make a pass through the object tree, which takes time, especially with many small objects. The major advantage is that it won’t take significant memory.

picklesize has special support for numpy arrays to calculate the size without the array->`str`->`file` procedure of regular pickling that requires at least two copy operations.

Usage

The API is kept similar to the one of pickle:

import picklesize
nbytes = picklesize.picklesize(obj, protocol=pickle.HIGHEST_PROTOCOL)

Currently only protocol 2 (better known as pickle.HIGHEST_PROTOCOL ) is supported.

Bug Reports and other contributions

This project is hosted here picklesize github page.

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

picklesize-0.1.1.zip (9.5 kB view details)

Uploaded Source

File details

Details for the file picklesize-0.1.1.zip.

File metadata

  • Download URL: picklesize-0.1.1.zip
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for picklesize-0.1.1.zip
Algorithm Hash digest
SHA256 2d1eaf0f6631f2ee7bcb5716671f9a17bafef79ba612d634b95c3ad20d21fd93
MD5 4718bceadda5b9b8f2e4b14e550c6e46
BLAKE2b-256 8b864006afb86ff69fad6a3c59750c7af2086c55752f8dd5e07038e09e0bc65a

See more details on using hashes here.

Supported by

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