getting the size of an object

Brett Hoerner bretthoerner at bretthoerner.com
Mon Jun 18 17:57:37 EDT 2007


On Jun 18, 2:48 pm, "filox" <filox_realmmakni... at yahoo.com> wrote:
> is there a long answer? what i want is to find out the number of bytes the
> object takes up in memory (during runtime). since python has a lot of
> introspection mechanisms i thought that should be no problem...

There isn't an automatic way through the language afaik.  I think
allocating memory in order to keep track of how much memory you have
allocated can begin to be a problem. And most people just don't care
down to each and every byte. :)

Some helpful information here:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/a7b9f3c03fb49aa/0e793beec82884f0?lnk=gst&q=size+object&rnum=4#0e793beec82884f0

Brett




More information about the Python-list mailing list