Python complements C++ for productivity

John Schmitt jschmitt at vmlabs.com
Wed Jun 21 14:15:14 EDT 2000


When I first opened Pythonwin, I used the Python/Perl phrasebook.  Very
useful to me.  I don't know the STL very well (I don't even know what the
SWIG is) so I couldn't write one, but how hard would be to write a Python
<-> C++/STL phrasebook?  I imagine it would be useful for C++ programmers
who want to move to Python and useful to Python programmers who have to move
some stuff to C++.

John

> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Don Bashford
> Sent: Tuesday, June 20, 2000 2:01 PM
> To: python-list at python.org
> Subject: Python complements C++ for productivity
>
>
> I've been using C++ for about 10 years, and Python less than a year.
> I recently had the experience of implementing an algorithm for
> Delaunay triangulation in both Python and C++.  I was working from my
> reading of someone's Ph.D. thesis that had parts of the algorithm in
> pseudo-code, and part in English.
>
> I started out in Python.  The work was pleasant and went fairly
> quickly.  It was pleasing that a lot of the Python I wrote ended up
> looking very close to the pseudo-code in the thesis.  The interpreted
> nature of Python was very helpful, since it made it easier to inspect
> results as I went along.  I also benefited from a Python graphics
> package written by a colleague that hepled me visualize what the
> algorithm was doing.  I think in the early phases, development in
> Python was faster than it would have been in C++.
>
> But the resulting code was slow---about 100 times slower than the
> thesis author's C code.  I started re-implementing in C++.  The
> similarity of the basic "class" ideas in the two languages made the
> re-write very easy and fast.  In some cases, I just dropped the Python
> code into the C++ file and edited it.   In the translation process,
> the stricter type rules of C++ helped me find some bugs that I might
> never have found in the Python version, and it also resulted in
> improved design.
>
> The only real unpleasentness in the whole process was when I had my
> implementation partly in Python (higher level) and partly in C++
> (lower, more number crunching levels).  Then I was using SWIG to
> "wrap" the C++ parts for use from Python, but getting proper handling
> of translations like Python lists to C++ containers was quite a pain
> (although I learned a lot about SWIG typemaps in the process).
>
> In short, I found Python to be a great prototyping language, with
> pretty easy movement to C++, which is a great language when you want
> strict type checking, data hiding and performance.
> --
> http://www.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list