Martin v. Löwis <mar...@v.loewis.de> added the comment:

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?

----------
nosy: +loewis

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12414>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to