Python Productivity over C++

Aahz Maruch aahz at netcom.com
Mon Jun 12 17:22:58 EDT 2000


In article <Pine.GSO.4.21.0006121559430.13331-100000 at y.glue.umd.edu>,
Roy Katz  <katz at Glue.umd.edu> wrote:
>
>I wanted to test this out, so I built a project in Python.  It is a small
>CPU emulator, implementing twelve or so basic instructions (push,
>pop, mov, add, interrupt-execute, etc...).  The time invested in its
>Python build amounted to two hours.  Mostly of the time was spent writing
>new code. 
>
>Then I moved it to C++.  In a nutshell, this required re-writing
>everything using STL.  This took me about twice as long to implement (not
>counting nitpicking over the syntax errors).
>
>Then I move to C.  The process took about twice as long as the C++
>attempt; not counting the time it took for me to write miscellaneous
>libraries (stack, memory allocation), I noticed that I was spending far
>more time hunting pointer bugs and syntax errors than writing new
>code. oThis was the longest port; it took me about four times longer than 
>it did in Python. 
>
>At the same time, C was faster than (straight) Python by a factor of
>ten.  Whatever, I now have three implementations of a virtual CPU to play 
>around with :)

The real moral is that, had you invested the same amount of time
speeding up your Python code (possibly by writing part of it in straight
C), you almost certainly would have received a speedup of somewhere
between two and a hundred times -- so at worst your C program would have
been five times faster and at best your C program would have been ten
times slower.  (Best and worst being relative to the Python program, of
course.  ;-)
--
                      --- Aahz (Copyright 2000 by aahz at netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

"I love you."
"Duhhhh!"  --SFJ



More information about the Python-list mailing list