[Tutor] Cython vs Python-C API
Jerry Hill
malaclypse2 at gmail.com
Mon Nov 14 23:02:02 CET 2011
On Mon, Nov 14, 2011 at 3:30 PM, Jaidev Deshpande <
deshpande.jaidev at gmail.com> wrote:
> Hi
>
> I need to perform cubic spline interpolation over a range of points, and I
> have written the code for the same in C and in Python.
>
> The interpolation is part of a bigger project. I want to front end for the
> project to be Python. Ideally I want Python only to deal with data
> visualization and i/o, and I'll leave the computationally expensive part of
> the project to C extensions, which can be imported as functions into Python.
>
> To this end, the interpolation can be handled in two ways:
>
> 1. I can either compile the C code into a module using the Python-C/C++
> API, through which I can simple 'import' the required function.
> 2. I can use the Python code and extend it using Cython.
>
> Which will give me a better performance?
>
Aren't you, right now, in the ideal position to answer that question for
yourself? You have the same algorithm implemented both in C and in
Python. Can't you compile that python code with Cython, then just test the
two to see which is faster?
--
Jerry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111114/750d6766/attachment.html>
More information about the Tutor
mailing list