[Python-Dev] PEP 42: sizeof(obj) builtin

Guido van Rossum guido@python.org
Fri, 31 Jan 2003 11:31:15 -0500


> Even a simple measure which double-counted everything might be
> useful to me.  Or perhaps a simple measure which counted only memory
> that would be freed by destroying this object.
> 
> I am after all looking for a needle (excessive memory usage) which
> is two orders of magnitude bigger than the hay (memory usage that I
> am sure I want).

You're going to have to think.  There's no magic answer.  Hire someone
who knows Python's implementation well, and they'll be able to tell
your the answer as fast as they can read your Python source code.

Unless it's a memory leak in C code (yours, not Python's).

> I don't know what the very *best* kind of answer would be.  Perhaps
> a recursively defined "weight", where an object which holds the
> *only* reference to another object carries the weight of that other
> object, and an object which holds one of K references to another
> object carries 1/Kth of its weight.  I'm not sure that would be
> useful, but it might be.

Too AI-like.

--Guido van Rossum (home page: http://www.python.org/~guido/)