Python: are objects more memory-hungry than dictionaries?
<pre><code>Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
# RAM usage: 2100
&gt;&gt;&gt; class Test:
...     def __init__(self, i):
...             self.one = i
...             self.hundred = 100*i
...
# RAM usage: 2108
&gt;&gt;&gt; list1 = [ Test(i) for i in xrange(10000) ]
# RAM usage: 4364
&gt;&gt;&gt; del(list1)
# RAM usage: 2780
&gt;&gt;&gt; list2 = [ {"one": i, "hundred": 100*i} for i in xrange(10000) ]
# RAM usage: 3960
&gt;&gt;&gt; del(list2)
# RAM usage: 2908
</code></pre>

<p>Why does a list of objects take twice as much memory as a list of equivalent dictionaries? I thought an object would be much more efficient since there is no need to store copies of attribute names for each object.</p>
