New submission from Robert Schuppenies <[EMAIL PROTECTED]>: 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. ---------- components: Interpreter Core files: footprint.patch keywords: patch messages: 66989 nosy: okkoto severity: normal status: open title: Add memory footprint query type: feature request versions: Python 2.6 Added file: http://bugs.python.org/file10353/footprint.patch __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2898> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com