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
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
File details
Details for the file picklesize-0.1.0.zip
.
File metadata
- Download URL: picklesize-0.1.0.zip
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdcbe1eb04b3cd24450a07f4f835ce42f8eaf529bf585a3bb4bf2b3cca9d1a59 |
|
MD5 | 84f72e36dd4ebc7e5cf250fedca91b35 |
|
BLAKE2b-256 | 4ba3aab262408a7007cf30b2f52c4a7b97b3c580b0f3b97be1616b540dc6ccea |