[Tutor] combining c and python

Oscar Benjamin oscar.j.benjamin at gmail.com
Tue Sep 18 01:54:56 CEST 2012


On 2012-09-17, Walter Prins <wprins at gmail.com> wrote:
> Hi Chris,
>
> On 17 September 2012 18:43, Chris Fuller <cfuller084 at thinkingplanet.net>
> wrote:
>> To run C alongside Python, you need to use the API.
>>
>> You can interface Cython with straight C, of course, but not in a way that
>> will work with the standard interpreter.
>
> Just to be clear, one of the main reasons for Cython's existence is to
> allow for the easy writing of CPython extension modules in a more or
> less Python like language which then gets compiled down to C for you
> (rather than you having to write the C yourself.)  Another is to allow
> you to easily wrap C libraries in such a way as to allow you to make
> them accessible from CPython.

Yeah, as a regular Cython user I'm not sure if I really understand Chris'
comments there.

Cython uses precisely that C-API to create the extension modules it makes. If
you've ever used the same C-API manually you'll understand why Cython exists
to make it easier.

Also, Cython *only* works with the standard interpreter (the latest release
claims alpha quality support for PyPy but I haven't tested that myself).

Oscar



More information about the Tutor mailing list