[issue10725] Better cache instrumentation

Antoine Pitrou report at bugs.python.org
Fri Dec 17 19:06:55 CET 2010


Antoine Pitrou <pitrou at free.fr> added the comment:

> Updated to use ABCs but still relies on user objects implementing
> __sizeof__.  So it is accurate whenever sys.getsizeof() is accurate.

I'm really -1 on this. It's better to give no measurement than to give a
totally wrong indication. The fact that you had to special-case
containers shows that getsizeof() is *not* the right solution for this.

(because if it was, you could rely on the containers' __sizeof__ instead
of overriding it)

The "size of an object and its contents" generally doesn't make any
sense, because the object graph is massively connected. getsizeof()
gives you the basic internal footprint of the object, but that's all.
It's really not a high-level tool for the everyday programmer, and
relying on it to say how much memory would be saved by getting rid of
certain objects is bogus.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10725>
_______________________________________


More information about the Python-bugs-list mailing list