objsize
Traversal over Python's objects subtree and calculate the total size of the subtree in bytes (deep size).
Decision gist · record as of 2026-08-14
Yes. objsize is a straightforward, dependency-free memory profiling tool with no known vulnerabilities, permissive licensing, and broad Python version support. Install it if you need to measure object memory consumption beyond what sys.getsizeof() provides. The aging maintenance status is not a blocker for a stable utility library, but check the documentation to confirm it handles your Python version and object types.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.8 or later.
- Low friction: pure Python wheel with no runtime dependencies and no compiled extensions.
- Package status is aging (208 days since last release), but the repository remains active and unarchived.
License · maintenance · safety
BSD-3-Clause (permissive) — BSD-3-Clause is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
last release 2026-01-18 (208 days) · last repo commit 2026-01-18 · 44 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 2,995,494 downloads/mo, #2,795 on PyPI
Alternatives
Verify before relying
pip install objsize==0.8.0
import objsize
# Measure deep size of a dict including all nested objects
size_bytes = objsize.get_deep_size(dict(arg1='hello', arg2='world'))
print(size_bytes) # 340
# Measure multiple objects
size_bytes = objsize.get_deep_size(['hello', 'world'], {'arg1': 'hello'})
print(size_bytes) # combined size- Whether the package handles all edge cases in modern Python versions beyond 3.8, or if there are known limitations with newer object types.
- Performance characteristics when traversing very large object graphs or deeply nested structures.
What it is and what it does
objsize is a Python library that calculates how much memory an object and all its nested children consume, measured in bytes. It uses Python's garbage collection mechanism to traverse object graphs without recursive calls, making it faster and safer than naive approaches. The package automatically filters out shared objects like None, types, modules, classes, and functions, since these are typically shared across many instances and shouldn't be counted multiple times.
You can measure single objects, multiple objects at once, or exclude specific subtrees from the calculation. The library offers customization hooks: you can define your own size calculation, referent discovery, and filtering logic to handle special cases like torch tensors or weakref proxies that don't expose their memory through Python's standard introspection. It also provides a traversal API to walk the entire object graph yourself.
Use it for
- Debug memory leaks by measuring which objects and their children are consuming unexpected amounts of memory.
- Profile data structure efficiency by comparing deep sizes of different implementations to find the most memory-efficient design.
- Monitor memory usage in long-running applications by periodically checking the size of key objects to detect gradual bloat.
- Analyze neural network models (e.g., torch tensors) by providing custom size handlers for framework-specific object types.
- Validate that cached or pooled objects aren't growing unexpectedly by comparing their sizes across application lifecycle.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
objsize is a straightforward, dependency-free memory profiling tool with no known vulnerabilities, permissive licensing, and broad Python version support. Install it if you need to measure object memory consumption beyond what sys.getsizeof() provides. The aging maintenance status is not a blocker for a stable utility library, but check the documentation to confirm it handles your Python version and object types.
Install
objsize on PyPI
Before you install
Low friction: pure Python wheel with no runtime dependencies and no compiled extensions. Package status is aging (208 days since last release), but the repository remains active and unarchived.
Requires Python 3.8 or later.
License in practice
BSD-3-Clause is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install objsize==0.8.0
import objsize
# Measure deep size of a dict including all nested objects
size_bytes = objsize.get_deep_size(dict(arg1='hello', arg2='world'))
print(size_bytes) # 340
# Measure multiple objects
size_bytes = objsize.get_deep_size(['hello', 'world'], {'arg1': 'hello'})
print(size_bytes) # combined size
Verify before relying
- Whether the package handles all edge cases in modern Python versions beyond 3.8, or if there are known limitations with newer object types.
- Performance characteristics when traversing very large object graphs or deeply nested structures.
Package facts
| License | BSD-3-Clause permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Aging 208 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,995,494 / month, #2,795 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Topic :: Software Development :: Libraries :: Python Modules |
Evidence: objsize-0.8.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “python object memory size”
- objsizeMeasures the complete memory footprint of Python objects including…
- PymplerPympler measures, monitors, and analyzes memory behavior of Python…
- guppy3Guppy 3 analyzes Python heap memory to identify object allocations,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also Pympler · tensordict · recursive-diff · deepdiff · backports.weakref · weakrefmethod · tensordict-nightly · anytree · objectory · lazy-object-proxy