where are the program that are written in python?

sturlamolden sturla at molden.no
Sun May 23 01:35:42 EDT 2010


On 22 Mai, 13:28, Tim Chase <python.l... at tim.thechases.com> wrote:

> Just as an aside, last I checked, mercurial had some core code in
> C for speed.  

I've been writing scrintific software for over 10 years. I always find
myself writing small pieces of C now and then. It is usally because
header files are too complicated to expose to Python. I will e.g. make
OpenGL calls from C, and then call the rendering routine from Python
with ctypes. It saves me the work of exposing OpenGL (or whatever) to
Python. There are already header files that make the API available to
C.

Yes I know about PyOpenGL, but then there is the speed argument: From
C I can make epeated calls to functions like glVertex4f with minial
loss of efficacy. Calling glVertex4f from Python (e.g. PyOpenGL) would
give me the Python (and possibly ctypes) overhead for each call, which
is considerable.

So there is the two arguments for using C now and then: (1) Save
programming time by not having to repeat header files and (2) make
programs run faster by avoiding the Python overhead. Some times it
matters, some times it don't. But it does not make sense to write C or
C++ all the time, nor does it help to use C or C++ for I/O bound
problems.











More information about the Python-list mailing list