Re: Running code from source that includes extension modules

Discussion in 'Python' started by Oscar Benjamin, Oct 3, 2013.

  1. On 2 October 2013 23:28, Michael Schwarz <> wrote:
    >
    > I will look into that too, that sounds very convenient. But am I right, that to use Cython the non-Python code needs to be written in the Cython language, which means I can't just copy&past C code into it? For my current project, this is exactly what I do, because the C code I use already existed.


    It's better than that. Don't copy/paste your code. Just declare it in
    Cython and you can call straight into the existing C functions cutting
    out most of the boilerplate involved in making C code accessible to
    Python:
    http://docs.cython.org/src/userguide/external_C_code.html

    You'll sometimes need a short Cython wrapper function to convert from
    Python types to corresponding C types. But this is about 5 lines of
    easy to read Cython code vs maybe 30 lines of hard to follow C code.

    Having written CPython extension modules both by hand and using Cython
    I strongly recommend to use Cython.


    Oscar
    Oscar Benjamin, Oct 3, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anand
    Replies:
    3
    Views:
    866
    Tim Daneliuk
    Nov 8, 2003
  2. Satabdi Mukherjee
    Replies:
    1
    Views:
    550
    Terry Jan Reedy
    Apr 4, 2013
  3. Michael Schwarz
    Replies:
    0
    Views:
    128
    Michael Schwarz
    Oct 2, 2013
  4. Gisle Vanem
    Replies:
    0
    Views:
    126
    Gisle Vanem
    Oct 2, 2013
  5. Stefan Behnel
    Replies:
    0
    Views:
    120
    Stefan Behnel
    Oct 2, 2013
Loading...

Share This Page