Mailing List Archive

Memory usage in Python
Dear all,

I've been reading this list for a while but this is the first time I
post a message. I am interested on using Python as a scripting
language for small embedded systems. One of the limiting factors on a
embedded system is the memory. Memory cost money, uses space and
drains power.

We have released a big patch to selectively disable some features of a
Python interpreter at compile time. With the patch, it is possible to
disable, i.e., complex numbers or file objects, in order to reduce
the memory foot print of the Python interpreter. The patch is
available at http://www.abo.fi/~iporres/python

Now, I am interested on studying and reducing the memory consumption of
Python programs. That is all the memory allocated by the interpreter
in order to run a python program. I would like to know if somebody
else has been working on the same direction. Is there any document
explaining how Python uses the memory? I would be nice to know which
structures are most used, their size, how often are accessed,
etc...

I have the impression that most people is concerned about optimising
Python for speed, but I still think that some Python users will
also benefit from size optimisations.

Ivan

--
Ivan Porres Paltor Turku Centre for Computer Science
Åbo Akademi, Department of Computer Science Phone: +358-2-2154033
Lemminkäinengatan 14A
FIN-20520 Turku - Finland http://www.abo.fi/~iporres
Re: Memory usage in Python [ In reply to ]
Ivan Porres wrote:
>
> Dear all,
>
> I've been reading this list for a while but this is the first time I
> post a message. I am interested on using Python as a scripting
> language for small embedded systems. One of the limiting factors on a
> embedded system is the memory. Memory cost money, uses space and
> drains power.
>
> We have released a big patch to selectively disable some features of a
> Python interpreter at compile time. With the patch, it is possible to
> disable, i.e., complex numbers or file objects, in order to reduce
> the memory foot print of the Python interpreter. The patch is
> available at http://www.abo.fi/~iporres/python
>
> Now, I am interested on studying and reducing the memory consumption of
> Python programs. That is all the memory allocated by the interpreter
> in order to run a python program. I would like to know if somebody
> else has been working on the same direction. Is there any document
> explaining how Python uses the memory? I would be nice to know which
> structures are most used, their size, how often are accessed,
> etc...

You should have a look at Vladimir Marangozov's pymalloc (hope this
URL still works):

http://sirac.inrialpes.fr/~marangoz/python/

It has some logging facilities which give detailed reports about
the storage sizes etc.

> I have the impression that most people is concerned about optimising
> Python for speed, but I still think that some Python users will
> also benefit from size optimisations.

--
Marc-Andre Lemburg
______________________________________________________________________
Y2000: 109 days left
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/