This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author loewis
Recipients benjamin.peterson, loewis
Date 2011-06-26.20:04:02
SpamBayes Score 7.897126e-07
Marked as misclassified No
Message-id <1309118643.34.0.831030686435.issue12414@psf.upfronthosting.co.za>
In-reply-to
Content
For composite objects, getsizeof should only return the memory of the object itself, and not that of other objects it refers to. "the object itself" definitely includes the struct of the object, and also definitely includes non-PyObject blocks uniquely referred to by the object. It definitely should not return objects it reports in gc.get_referents. It probably should include PyObjects not shared with any other object, and not accessible from outside of the object.

There are boundary cases, such as memory blocks which are not PyObject, but may be shared across objects, and PyObjects not reported in get_referents.

It seems this case is the latter: the PyObjects are not returned from get_referents, but are certainly available to Python, e.g. through co_code and co_consts.

I don't think there sizes should be added to the size of the PyObject, since otherwise accounting algorithms may account for it twice.

What's your use case for including it in the total size?
History
Date User Action Args
2011-06-26 20:04:03loewissetrecipients: + loewis, benjamin.peterson
2011-06-26 20:04:03loewissetmessageid: <1309118643.34.0.831030686435.issue12414@psf.upfronthosting.co.za>
2011-06-26 20:04:02loewislinkissue12414 messages
2011-06-26 20:04:02loewiscreate