擅长:python、mysql、java
<p>从<a href="http://docs.python.org/dev/library/sys.html#sys.getsizeof" rel="noreferrer">PythonDocs</a></p>
<blockquote>
<p>See <a href="http://code.activestate.com/recipes/577504/" rel="noreferrer">recursive sizeof recipe</a> for an example of using getsizeof() recursively to find the size of containers and all their contents.</p>
</blockquote>
<p>所以它只计算开销,但是可以使用<a href="http://code.activestate.com/recipes/577504/" rel="noreferrer">this link</a>中的函数为dict之类的容器计算开销。</p>