Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #55406 > unrolled thread

Re: Running code from source that includes extension modules

Started byOscar Benjamin <oscar.j.benjamin@gmail.com>
First post2013-10-03 10:01 +0100
Last post2013-10-03 10:01 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Running code from source that includes extension modules Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-10-03 10:01 +0100

#55406 — Re: Running code from source that includes extension modules

FromOscar Benjamin <oscar.j.benjamin@gmail.com>
Date2013-10-03 10:01 +0100
SubjectRe: Running code from source that includes extension modules
Message-ID<mailman.673.1380790933.18130.python-list@python.org>
On 2 October 2013 23:28, Michael Schwarz <michi.schwarz@gmail.com> 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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web