<p dir="auto">sys.getsizeof() uses the <code class="notranslate">__sizeof__</code> method, if defined, to return a Python object's full memory footprint (including owned data areas that lay outside of the basic object structure).</p>
<p dir="auto">Currently:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; x = np.zeros((20000,))
&gt;&gt;&gt; x.nbytes 
160000
&gt;&gt;&gt; sys.getsizeof(x)
80"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; x = np.zeros((20000,))
&gt;&gt;&gt; x.nbytes 
160000
&gt;&gt;&gt; sys.getsizeof(x)
80
</code></pre></div>
<p dir="auto">On the other hand, since the underlying buffer can be shared by several objects, it's not obvious how non-misleading the answer would be.</p>
<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/1683" rel="nofollow">http://projects.scipy.org/numpy/ticket/1683</a> on 2010-11-22 by trac user ghazel, assigned to unknown.</em></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; sys.getsizeof(numpy.array([]))
80
&gt;&gt;&gt; sys.getsizeof(numpy.array(range(100000)))
80"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; sys.getsizeof(numpy.array([]))
80
&gt;&gt;&gt; sys.getsizeof(numpy.array(range(100000)))
80
</code></pre></div>