Cython - Best Programming language Ever

Joined
5/2/06
Messages
12,166
Points
273
If you never heard of Cython, the author of this article claims it's the best programming language in the world.
What is Cython?
Well Cython is Python. It will accept any Python code , even Python 3 , subject to some limitation because it is an ongoing project .

However Cython is more than python. The first thing making Cython different is that it converts python code to C code. This code can be compiled with any C compliant compiler and produce either an executable or dynamic linked library (Known as DLL on windows) .

Cython Advantages
  1. 100% Python syntax, making dead easy to use and code with. You can use any existing python code with no change to your code.
  2. C speed, cause it supports many of the features of C language making it extremely faster alot faster than psyco and ctypes.There is some overhead because of the conversion but it usually quite small from 40% to 100%. However there have been benchmarks that have show Cython outperform C by 40% which is is not unusual. Usually for statically typed variable except a boost in speed from 50 to 1000 times compared to the same python code
  3. you can use any C code any time, just import it and it becomes accessible to your Cython code. Excellent for wrapping C libraries
  4. Cython now supports C and C++.
  5. You never need to mess with C code all happens from inside python syntax.
  6. Converts the python code to C code. Well I do not know how useful that is as a few lines of python code turns to thousnads of lines of c code but for those who want to edit code to kingdom come it will be useful. Again I remind you that Cython does not force you to write any C code to take enjoy its advantages.
  7. Cython can be compiled to dynamic link libraries that can be imported and used like any python library out there.
  8. Has the support of Google , so it is actively developed.
Disadvantages
  1. Cython is Python, meaning it will still require python installation and will run from inside a python VM as any python app. I dont know whether this is a disadvantage per se but for those that think that what to consider Cython as a complete replacement to C , must take this into consideration.
  2. Its does not offer automatic wrapping for C libaries like Swig , so if you want to wrap Alot of C functions/ Libraries , then Cython is not the best tool for that job , but it may provide support for this in the future.
Sum Up
Cython offers C speed from inside python with a tiny amount of recoding, it can be uses . Bare in mind that it offers alot of C features not mentioned here so the best you can do is visit the website and read the excellent documentation .

Here is the Cython website. http://cython.org/
 
Cython has variable typing which means that going back to Python is tricky, but yes it does seem to be in a sweet spot between performance and productivity. It's in a few banks already.
 
Back
Top Bottom