Re:Using the Cython Compiler to write fast Python code
by mace on Friday October 29, 2010 @01:24AM
(#1846269)
Pure C extensions will give you the best performance. If you write really modular C code, interop with it and Python is really clean.
Cython is interesting, but as cited, there are also some limitations and caveats. See http://docs.cython.org/src/userguide/limitations.html and http://docs.cython.org/src/tutorial/caveats.html
Re:Using the Cython Compiler to write fast Python code
by swolchok on Friday October 29, 2010 @03:14AM
(#1846462)
Cython is not a bad story for C interop, though. See e.g. pyevent (http://code.google.com/p/pyevent/), which provides Python bindings to libevent. Be warned: until there's a new release of pyevent (0.4), you should, in my opinion, use the SVN version.
Re:Using the Cython Compiler to write fast Python code
by mturmon on Friday October 29, 2010 @02:17AM
(#1846364)
I very much agree with this. Especially if you use similar C library interfacing styles, you can reuse or abstract out the glue parts easily.
About playing on both sides of the efficiency/expressiveness spectrum, the important thing is to be sure to do real benchmarks so you only drop down into C when it pays off.
Sometimes, the reasons are not just efficiency -- you may already have C code that does the right thing.
With C and Python you get to play on both ends of the spectrum -- concise clear code, and high performance code with C.