some comments for Python 3000

Rainer Deyke root at rainerdeyke.com
Mon Aug 14 15:11:27 EDT 2000


"Janne Sinkkonen" <janne at nnets.fi> wrote in message
news:m3sns7agsa.fsf at kinos.nnets.fi...
> "Rainer Deyke" <root at rainerdeyke.com> writes:
>
> > Much worse, in fact.  In some cases, C outperforms Python by over 100:1.
> > And memory usage is even worse.  In C, I can have a integer variable
with
> > range 0 to 255 in a single byte.  In Python, I need at least two objects
> > (the integer and the string that holds the integer's name), both
allocated
> > on the stack (with whatever overhead this entails), both with four bytes
> > reference count and four bytes pointer to the type object, plus the
contents
> > which are again at least four bytes each, plus one byte for each
character
> > in the variable name - and that isn't counting the extra storage needed
for
> > the entry in the dictionary (another eight bytes on average at least).
> > That's worse than 64:1.  Even if the C version uses four bytes for the
> > integer, it's 16:1.
>
> If you have so many character objects that the above-mentioned memory
> overhead is significant, there is usually some structure in the object
> set which makes the use of strings, arrays (like Int8 of the Numeric
> module), external data bases or some other compact representation
> desirable. If not, then Python is not the right for the task.

If for any C program the equivalent Python program takes 16 times as much
memory, then the overhead will always be significant for programs of medium
size or above, and Python will never become a truly general purpose
language.  I see this as the major factor keeping Python from becoming more
popular.  I'm not complaining, since I don't really mind using C/C++ where
appropriate.


--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list