Ignore singletons

This commit is contained in:
Erik Johnston 2021-04-26 10:29:26 +01:00
parent 5003bd29d2
commit 0c9bab290f

View file

@ -44,6 +44,10 @@ try:
recurse: If true will include referenced values in the size,
otherwise only sizes the given object.
"""
# Ignore singleton values when calculating memory usage.
if val in ((), None, ""):
return 0
sizer = Asizer()
sizer.exclude_refs((), None, "")
return sizer.asizeof(val, limit=100 if recurse else 0)