Estimating memory use?

Roy Smith roy at panix.com
Sun Nov 27 15:06:25 CET 2005


I've got a large text processing task to attack (it's actually a genomics 
task; matching DNA probes against bacterial genomes).  I've got roughly 
200,000 probes, each of which is a 25 character long text string.  My first 
thought is to compile these into 200,000 regexes, but before I launch into 
that, I want to do a back of the envelope guess as to how much memory that 
will take.

Is there any easy way to find out how much memory a Python object takes?  
If there was, it would be simple to compile a random small collection of 
these patterns (say, 100 of them), and add up the sizes of the resulting 
regex objects to get a rough idea of how much memory I'll need.  I realize 
I could just compile them all and watch the size of the Python process 
grow, but that seems somewhat brute force.



More information about the Python-list mailing list