Mikkel Krøigård <[EMAIL PROTECTED]> writes:
> I also found the following lines interesting:
>
> # Round to nearest multiple of 8 bytes
> x = size % 8
> if x != 0:
> size += 8-x
> size = (size + 8)
>
> Say size is 20 (as in the case of an integer). Then x is 4. We do
> the rest and size becomes 32, which is not the nearest multiple of 8
> bytes. Someone want to explain this to me? :)
>
> Anyone interested in this should probably read the source
> http://mail.python.org/pipermail/python-list/2002-March/135223.html
> which I think does a better job of explaining it.
Yeah, you're right, the source is better. It mentions an overhead of
144 bytes for a dict -- every object contain such a guy by default...
I tried this code:
>>> class X(object):
... __slots__ = ('foo',) # No dict, space for one attribte only.
... def __init__(self, foo):
... self.foo = foo
...
>>> class Y(object):
... def __init__(self, foo):
... self.foo = foo
and it turns out that X objects take up about 40 bytes in memory
whereas Y objects take up 180 bytes in memory. So the 144 byte
overhead per dict is quite real :-)
So a possible way to save space would be to make and use a new
DietDeferred class instead of the usual Deferred class.
I guess we should take this up with the Twisted guys too...
--
Martin Geisler
_______________________________________________
viff-devel mailing list (http://viff.dk/)
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk