Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #55406
| References | <CABdB9Z4rvKmO0bdZrmBd4Cy6b1OJyzkFMNpwmrR=k55J1X39wg@mail.gmail.com> <l2hrbf$uc9$1@ger.gmane.org> <D501DF32-45A1-4297-A1E0-3303B8212B23@gmail.com> |
|---|---|
| From | Oscar Benjamin <oscar.j.benjamin@gmail.com> |
| Date | 2013-10-03 10:01 +0100 |
| Subject | Re: Running code from source that includes extension modules |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.673.1380790933.18130.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Running code from source that includes extension modules Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-10-03 10:01 +0100
csiph-web