#!/usr/bin/env python # encoding: utf-8 # # Copyright (c) 2009 Doug Hellmann All rights reserved. # """ """ #end_pymotw_header import sys class WithAttributes(object): def __init__(self): self.a = 'a' self.b = 'b' return def __sizeof__(self): return object.__sizeof__(self) + \ sum(sys.getsizeof(v) for v in self.__dict__.values()) my_inst = WithAttributes() print sys.getsizeof(my_inst)