[Tutor] Why is an instance smaller than the sum of its components?

Jugurtha Hadjar jugurtha.hadjar at gmail.com
Tue Feb 3 23:40:33 CET 2015


On 02/03/2015 10:57 PM, Danny Yoo wrote:

> But what is the documented behavior of sys.getsizeof?
>
> Reading...
>
>      https://docs.python.org/3/library/sys.html#sys.getsizeof
>

Ah !

I was reading this:

	https://docs.python.org/2/library/sys.html#sys.getsizeof


The unlocking phrase:

> "Only the memory consumption directly attributed to the object is
> accounted for, not the memory consumption of objects it refers to."
>

seems to be present in the Python 3 doc, but not in Python 2's. I'll 
make sure to include the version in my future questions.


> But the docs there also have a link to a recursive getsizeof() recipe
> that does what I think you intend.  Take a look at that recipe.
>
>
> Good luck!
>

Yeap, I see that. Thanks for your time!

-- 
~Jugurtha Hadjar,


More information about the Tutor mailing list