Calculates the deep size of Python's objects.
Project description
objsize
Calculates an object deep size.
This module uses python internal GC implementation
to traverse all decedent objects.
It ignores type objects (isinstance(o, type)
)
such as classes and modules as they are common among all objects.
It is implemented without recursive calls
for best performance.
Install
pip install objsize
Usage
from objsize import get_deep_size
my_data = (list(range(5)), list(range(10)))
class MyClass:
def __init__(self, x, y):
self.x = x
self.y = y
self.d = {'x': x, 'y': y, 'self': self}
my_obj = MyClass(*my_data)
# Calculates my_obj deep size, including its stored data.
print(get_deep_size(my_obj))
# 1012
# Calculates my_obj deep size, ignoring non exclusive
# objects such as the ones stores in my_data.
print(get_deep_size(my_obj, only_exclusive=True))
# 408
License
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
objsize-0.2.1.tar.gz
(16.5 kB
view hashes)
Built Distribution
Close
Hashes for objsize-0.2.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb373a614c9280a6cf6e691cd3ea3031d086ecc8f388462c9827e8bac207fd43 |
|
MD5 | 1a7a9519cebe47ca8fd5d961507dca7c |
|
BLAKE2b-256 | 658eb120bd6df01a2c8c2abaf70df73400cc640010d79c02e5bd2533a17a17ab |