[Tutor] Memory consumption question

Bart Cramer bart.cramer at gmail.com
Thu Nov 15 16:56:59 CET 2007


Dear all,

I have a question... :

>>> class A: pass
...
>>> class B(object) : pass
...
>>> dir(A)
['__doc__', '__module__']
>>> dir(B)
['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__',
'__hash__', '__init__', '__module__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__']

What is the difference between classes A and B? The funny thing is, when I
put these things into an array of length, say, a million, it turns out that
class A eats about 184 bytes per instantiation, and class B a lot less
(sic!): plm 50 bytes. How come?

Best,

Bart.

-- 
Bart Cramer

Dudweilerstrasse 31
66111 Saarbrucken, Germany
0049 1577 6806119 (NEW!)

Bedumerstraat 25
9716 BB Groningen, the Netherlands
0031 6 42440326

bart.cramer at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071115/8fa226ec/attachment-0001.htm 


More information about the Tutor mailing list