Serhiy Storchaka added the comment:

There is an existing protocol for estimating the size of allocated memory. 
__sizeof__. Python API sys.getsizeof() and C API _PySys_GetSizeOf(). But it is 
too heavy for using in GC.

As a fast approximation the default implementation of the __sizeof__ method can 
be used:

    tp_basicsize + tp_itemsize * Py_SIZE(self)

----------
nosy: +serhiy.storchaka

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

Reply via email to