Python speed vs csharp
Juha Autero
Juha.Autero at iki.fi
Thu Jul 31 07:00:54 EDT 2003
Mike <mike at nospam.com> writes:
> Since the test case code was fairly small, I
> translated it to C and ran it. The C code runs in approximately 7.5
> seconds. That's compelling, but C isn't: part of my simulation includes a
> parser to read an input file. I put that together in a few minutes in
> Python, but there are no corresponding string or regex libraries with my C
> compiler, so converting my Python code would take far more time than I'd
> save during the resulting simulations.
So, write only most executed parts with C as C extension to
Python. This is the reason I like Python. If your program is not fast
enough, you can implement critical functions with C. For example the
error function would be very simple to turn into an C extension module
using "Extending and Embedding the Python Interpreter" document from
<URL: http://www.python.org/doc/current/ext/ext.html>.
There are several tools that make writing C extensions easier. I've
used SWIG and Pyrex.
--
Juha Autero
http://www.iki.fi/jautero/
Eschew obscurity!
More information about the Python-list
mailing list