Python memory use (psyco, C++)

Paul Rubin http
Mon Jun 21 19:26:45 CEST 2004


Roy Smith <roy at panix.com> writes:
> I understand that psyco significantly increases memory use.  Is that for 
> code or data? 

It's for code.  Psyco generates code on the fly each time it hits a new
combination of datatypes anyplace in the code.

> More specifically, if I've got a memory intensive 
> application (it might use 100's of Mbytes of data), should I expect 
> memory use to go up significantly under psyco?

Probably not.

> Also, for that memory intensive application, how should I expect Python 
> memory use to compare with C++?  I'm really only interested in data; the 
> memory needed to store the code is almost certainly insignificant in 
> either case.
>
> The data is a large number of small objects, interconnected in various 
> data structures, not just one huge block of raw data.

If you just code straightforwardly, Python will use a lot more memory.
There may be simple, application-specific things you can do to reduce
the memory footprint.

> I know all of the above is very vague, but I'm just trying to get a 
> rough idea if a Python implementation is feasable (or at least 
> plausable).  If a C++ version takes 300 Mbytes and a Python version 
> takes 1 Gig, that's probably not going to work.  Are there any rules of 
> thumb I could use to get a first-order estimate?

There's a minimum of around 12 (?) bytes of overhead for any Python
object including integers.  So if your objects are all very small, you
will get killed.  



More information about the Python-list mailing list