Author schuppenies
Recipients schuppenies
Date 2008-05-17.10:44:04
SpamBayes Score 0.0694294
Marked as misclassified No
Message-id <1211021071.55.0.0441674888284.issue2898@psf.upfronthosting.co.za>
In-reply-to
Content
I propose a patch which allows to query the memory footprint of an
object. Calling 'footprint(o)', a python developer can retrieve the
size of any python object. Only the size of the object itself will be
returned, the size of any referenced objects will be ignored.

The patch implements a generic function to compute the object
size. This works in most, but a few cases. One of these exceptions is
the dictionary with its particular table implementation. Such cases
can be handled by implementing an optional method in C. This would
also be the case for third-party implementations with unusual type
definitions.

One advantage with this approach is that the object size can be
computed at the level an object is allocated, not requiring complex
computations and considerations on higher levels.

I am not completely happy with the name 'footprint', but think using
'sizeof' would be confused with plain 'size', and 'memory_usage' was
somewhat too long to be typed conveniently.

Current test pass on linux32 and linux64, but the test suite is not
complete, yet.

This patch is part of my Google Summer of Code project on Python
memory profiling
(http://code.google.com/soc/2008/psf/appinfo.html?csaid=13F0E9C8B6E064EF).
Also, this is my first patch, so please let me know where missed
something, did not follow coding conventions, or made wrong
assumptions.
History
Date User Action Args
2008-05-17 10:44:32schuppeniessetspambayes_score: 0.0694294 -> 0.0694294
recipients: + schuppenies
2008-05-17 10:44:31schuppeniessetspambayes_score: 0.0694294 -> 0.0694294
messageid: <1211021071.55.0.0441674888284.issue2898@psf.upfronthosting.co.za>
2008-05-17 10:44:28schuppenieslinkissue2898 messages
2008-05-17 10:44:23schuppeniescreate