Skip to main content

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

GPL

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

objsize-0.2.1.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

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

objsize-0.2.1-py2.py3-none-any.whl (3.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file objsize-0.2.1.tar.gz.

File metadata

  • Download URL: objsize-0.2.1.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for objsize-0.2.1.tar.gz
Algorithm Hash digest
SHA256 7859bf1be122508c8cf4fabc1c2041ff7c87851e9502233ab3ba6930f0483bd2
MD5 adf0ad9230964739ff223a285bcfb2e7
BLAKE2b-256 465d08c506279a200ff1eef5e324dc3388e0382d074f28e90c16ca96b4994d3f

See more details on using hashes here.

File details

Details for the file objsize-0.2.1-py2.py3-none-any.whl.

File metadata

  • Download URL: objsize-0.2.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for objsize-0.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fb373a614c9280a6cf6e691cd3ea3031d086ecc8f388462c9827e8bac207fd43
MD5 1a7a9519cebe47ca8fd5d961507dca7c
BLAKE2b-256 658eb120bd6df01a2c8c2abaf70df73400cc640010d79c02e5bd2533a17a17ab

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