[Python-bugs-list] Find out size of primitive object (PR#214)

loewis@informatik.hu-berlin.de loewis@informatik.hu-berlin.de
Fri, 25 Feb 2000 14:28:35 -0500 (EST)


Full_Name: Martin v. Löwis
Version: 1.5.2
OS: Solaris
Submission from: pandora.informatik.hu-berlin.de (141.20.23.176)


This is a feature request made on python-help. If you want to estimate
how much memory your application uses, you currently have to count the bytes
manually. If there was a builtin function (say, sys.sizeof), counting would
be much easier. It would be documented as

sizeof(object) -> integer
Return the number of bytes that an object uses internally. This only counts
the number of bytes used by the object itself, not those of any of its 
attributes.

Ie. sys.sizeof(0) would give 12 on my system, the size of a dictionary would
count the dictentries, but the size of an instanceobject would not count the
the size of the __dict__ attribute.