Python script and C++

George Sakkis george.sakkis at gmail.com
Mon Nov 27 21:42:54 EST 2006


Thuan Seah Tan wrote:
> Hi all,
>
>     I am new to python  and currently I am working on a traffic simulation
> which I plan to define the various agents using scripting. It's kind of like
> scripting for non-playable character in games. I am thinking of using python
> for this but I am concerned with running time. Is scripting a lot slower
> compared to direct implementation in C++? Does compiling the script help in
> any way? Also, can anyone recommend me a book that covers python in general
> as well as C++ binding? Thanks.

Even if pure python turns out to be slow for some critical parts of
your application, there are quite a few ways to deal with it: psyco,
pyrex, weave/blitz, ctypes, SWIG, Boost-python, SIP, CXX, SCXX,
hand-written C extensions and perhaps more. Visit
http://www.scipy.org/PerformancePython for an example of taking a
simple pure Python function and boosting it using several different
tools. Check out the final comparison table first; the pyrex version is
less than half a second slower than the C++.

George




More information about the Python-list mailing list