Another minor patch

This commit is contained in:
Miroslav Stampar 2015-01-07 10:49:15 +01:00
parent 83add9fd9b
commit 47af7dfe6a

View File

@ -10,6 +10,7 @@ try:
except: except:
import pickle import pickle
import itertools
import os import os
import sys import sys
import tempfile import tempfile
@ -24,7 +25,9 @@ def _size_of(object):
""" """
retval = sys.getsizeof(object) retval = sys.getsizeof(object)
if hasattr(object, "__iter__"): if isinstance(object, dict):
retval += sum(_size_of(_) for _ in itertools.chain.from_iterable(object.items()))
elif hasattr(object, "__iter__"):
retval += sum(_size_of(_) for _ in object) retval += sum(_size_of(_) for _ in object)
return retval return retval