473,387 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Python memory use (psyco, C++)

I understand that psyco significantly increases memory use. Is that for
code or data? 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?

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.

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?
Jul 18 '05 #1
4 1710
On Mon, 21 Jun 2004 12:28:33 -0400, Roy Smith wrote:
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?


Why wouldn't it work? Memory is still quite cheap. If this is an app of
any complexity, the development time saved vs C++ will probably far more
than additional memory would cost.

Jul 18 '05 #2
In article <pa****************************@gmail.com>,
Tyler Eaves <ty****@gmail.com> wrote:
On Mon, 21 Jun 2004 12:28:33 -0400, Roy Smith wrote:
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?


Why wouldn't it work? Memory is still quite cheap. If this is an app of
any complexity, the development time saved vs C++ will probably far more
than additional memory would cost.


Because memory use is one of the constraints I was given to work with.
Jul 18 '05 #3
Roy Smith <ro*@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.
Jul 18 '05 #4

"Roy Smith" <ro*@panix.com> wrote in message
news:ro***********************@reader2.panix.com.. .
I understand that psyco significantly increases memory use. Is that for
code or data?
Code. The amount depends on how much code is psycoized and how many
specialized versions of each block of code it ends up compiling. I have
the impression that the amount is perhaps megabytes, not 10s of megabytes.
Also, for that memory intensive application, how should I expect Python
memory use to compare with C++?


If you have large arrays of numbers and use Numerical Python or Numarray,
space and speed are comparable. If you have large chunks of text (millions
of bytes each), space is about same. If you have millions of separate
objects (network, dict with millions of 6 byte words), then I expect memory
overhead of Python to be larger, perhaps enough to be a problem. A more
specific description of your situation will get more specific answers,
possibly with specific ways to reduce bloat.

Terry J. Reedy
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Michele Simionato | last post by:
I posted this few weeks ago (remember the C Sharp thread?) but it went unnoticed on the large mass of posts, so let me retry. Here I get Python+ Psyco twice as fast as optimized C, so I would like...
467
by: mike420 | last post by:
THE GOOD: 1. pickle 2. simplicity and uniformity 3. big library (bigger would be even better) THE BAD:
36
by: Armin Rigo | last post by:
Hi! This is a rant against the optimization trend of the Python interpreter. Sorting a list of 100000 integers in random order takes: * 0.75 seconds in Python 2.1 * 0.51 seconds in Python...
7
by: stormslayer | last post by:
Folks: I've been considering a shift to python. I currently use c++builder (borland) or perl. I do computational models / statistics programming, and was interested in python b/c it a. has...
34
by: Maboroshi | last post by:
Hello My question has to do with python and linux - I was interested in finding out what it would take to reimplement the Linux Kernel in python basically just taking the source code from linux...
25
by: abhinav | last post by:
Hello guys, I am a novice in python.I have to implement a full fledged mail server ..But i am not able to choose the language.Should i go for C(socket API) or python for this project? What are the...
8
by: . | last post by:
What is the fast way for a fast implementation of Python? -- JavaScript implementation of Python http://groups.google.it/group/JSython/
83
by: Licheng Fang | last post by:
Hi, I'm learning STL and I wrote some simple code to compare the efficiency of python and STL. //C++ #include <iostream> #include <string> #include <vector> #include <set> #include...
9
by: igor.tatarinov | last post by:
Hi, I am pretty new to Python and trying to use it for a relatively simple problem of loading a 5 million line text file and converting it into a few binary files. The text file has a fixed format...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.