[Tutor] object size in python is in what units?

Alan Gauld alan.gauld at btinternet.com
Tue Jul 23 21:02:12 CEST 2013


On 23/07/13 19:27, Jim Mooney wrote:

> And yet I still get 36 with this:
>
> bigKronk = Kronk('supercalifracilisticexpalidocious, even though the
> sound of it is really quite atrocious')
> sys.getsizeof(bigKronk)
> 36
>
> So I guess the object is only pointing to its contents.

Python namespaces are effectively dictionaries binding a name
with an object reference.  The object in turn is like a dictionary 
referring to the values. So I guess you are seeing the object
container size.

> means an object is just a bunch of names bound to pointers.

Pretty much everything in Python looks like a dictionary
so I'd guess you are correct.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list