Size of an object in memory?

Fernando Pérez fperez528 at yahoo.com
Wed Nov 14 10:25:11 EST 2001


Michael Hudson wrote:

> Fernando Pérez <fperez528 at yahoo.com> writes:
> 
>> Is there any way (at runtime, dynamically) to obtain the size in
>> bytes of a given object in memory?
> 
> Didn't we do this a few days ago?  See this thread:
> 
>     
http://groups.google.com/groups?hl=en&threadm=_6FG7.33159%24i4.5175661%40news0.telusplanet.net&rnum=1
> 
> but, in short, no, and you don't really want to know.
> 

Sorry to bug, but I'm new to the list and I'm not sure which thread you're 
talking about. If I hit the link you provide I get a blank in google. Could 
you repost the correct link if you have it handy?


>> Since multiple names may be bound to the same object, is it possible
>> to obtain the size of the underlying object and a list of all other
>> names bound to it?
> 
> Not easily.  Or maybe not at all.  Oh, hang on: see gc.get_referents.
> This may be new in Python 2.2, though.
> 

Thanks for the tip. I'll look into it when I get 2.2 on.

Cheers,

F.



More information about the Python-list mailing list