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.
Metadata
Release files for picklesize 0.1.1
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 | Actions |
|---|---|---|---|---|
| picklesize-0.1.1.zip | 9.5 kB | Without provenance | Details for picklesize-0.1.1.zip |
Release files / picklesize-0.1.1.zip
| Download URL | picklesize-0.1.1.zip |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d1eaf0f6631f2ee7bcb5716671f9a17bafef79ba612d634b95c3ad20d21fd93
|
|
BLAKE2b-256 checksum How to use checksums |
8b864006afb86ff69fad6a3c59750c7af2086c55752f8dd5e07038e09e0bc65a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for picklesize 0.1.1
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.