On Mon, Mar 28, 2011 at 7:18 PM, Chris Angelico <ros...@gmail.com> wrote: > I have an application that embeds Python to allow third-party > scripting. The Python code returns data to the application in the form > of a list or dictionary, and I'd like to have a quick check on the > size of the outputted object before my code goes too deep into > processing it.
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. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list