Running code from source that includes extension modules
Oscar Benjamin
oscar.j.benjamin at gmail.com
Thu Oct 3 05:01:44 EDT 2013
More information about the Python-list mailing list
Thu Oct 3 05:01:44 EDT 2013
- Previous message (by thread): Running code from source that includes extension modules
- Next message (by thread): Rounding off Values of dicts (in a list) to 2 decimal points
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2 October 2013 23:28, Michael Schwarz <michi.schwarz at 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
- Previous message (by thread): Running code from source that includes extension modules
- Next message (by thread): Rounding off Values of dicts (in a list) to 2 decimal points
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list