def _size_of(object_):
 retval = sys.getsizeof(object_, DEFAULT_SIZE_OF)
 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_))
 return retval

def _size_of ( object_ ) : retval = sys . getsizeof ( object_ , DEFAULT_SIZE_OF ) 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_ ) ) return retval
returns total size of a given object_ .