Embedding Python: estimate size of dict/list

Chris Angelico rosuav at gmail.com
Mon Mar 28 20:26:46 EDT 2011


On Tue, Mar 29, 2011 at 10:56 AM, Jerry Hill <malaclypse2 at gmail.com> wrote:
> For python 2.6 and later, sys.getsizeof() will probably do what you
> want.  It relies on objects implementing a __sizeof__() method, so
> third-party objects may or may not support this, but since you're
> looking at dicts and lists, you should be all set.

Based on the docs and http://code.activestate.com/recipes/577504/ I
understand that to be non-recursive. I'm guessing then that there
isn't a recursive version, and that it's best to recurse myself?

Chris Angelico



More information about the Python-list mailing list