Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Embedding Python: estimate size of dict/list

Reply
Thread Tools

Embedding Python: estimate size of dict/list

 
 
Chris Angelico
Guest
Posts: n/a
 
      03-28-2011
Hi! New to the list, apologies if I'm in breach of protocol.

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.

Obviously I could use PyObject_Str() and PyString_Size() to get a
decent figure, but that seems like overkill.

What I'm hoping for is some simple function that zips through a
complex object and sums its approximate memory usage. Is there one?

It doesn't have to be 100% precise; I just want to distinguish between
the normal (under a KB, or maybe a couple KB at most) and the
ridiculous (megs and megs of junk that I'd have to process and send
over the network only for it to be discarded at the other end). If
there's some sort of "if this ran out of references now, how much
memory would be freed" function, that would be awesome.

My code is in C++, is embedding Python 2.6.6, and is running on Ubuntu
Linux. If the solution is to move to Python 3.x then this may be an
option.

Hoping there's something around!

Chris Angelico
aka Rosuav
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Estimate IFInOctets on multilink interface anti00@poczta.onet.pl Cisco 1 12-01-2005 05:49 PM
cost estimate for a database-driven web site =?Utf-8?B?dmlrdG9yOTk5MA==?= ASP .Net 0 06-05-2005 09:45 PM
cost estimate for a database-driven web site =?Utf-8?B?dmlrdG9yOTk5MA==?= ASP .Net 0 06-05-2005 09:31 PM
Estimate of hours to be spent on a project Bob ASP .Net 31 07-16-2004 03:01 PM
Give me your estimate... MCSE 8 04-05-2004 11:59 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57