Martin Geisler <[EMAIL PROTECTED]> writes: > http://groups.google.dk/group/comp.lang.python/msg/4e0f9800c5898334 > > Using the heuristic there, an integer takes up 32 bytes and an empty > list takes up 40 bytes! Ugh...
I have not used them much, but I guess this is one of the reasons why the array module and NumPy exists: http://docs.python.org/lib/module-array.html http://numpy.org/ They allow you to allocate arrays of simple types (in the case of the array module) or arbitrary objects (with NumPy) which take up the space you expect. For example, with the array module this code: >>> from array import * >>> a = array('i', xrange(10**7)) really does take up 40 MiB as one would hope. But of course that does not solve our problem with using many Deferreds. This code: >>> from numpy import * >>> from twisted.internet.defer import * >>> a = array([Deferred() for x in xrange(10**5)]) still takes up about 20 MiB... One possibility would be to change from array([ ... lots of Deferreds ... ]) to Deferred(array([ ... data ... ])) That would cut down on the memory usage, but destroy the parallellization. -- Martin Geisler _______________________________________________ viff-devel mailing list (http://viff.dk/) [email protected] http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk
