Hello world!


Yeah! The blog is born. This is a blog for my Google Summer of Code project for Cython, which is aimed on improve Cython’s support for Python 3 and pure Python mode.  This project will include two stages. The first stage will fix several Cython bugs, and in the second stage some new features will be implemented.

As you know, Cython is a compiler that compiles Python code, or more precisely a language defined as a superset of Python, to C/C++ code. The compiled code could be 5 – 100x faster than plain Python, and what you pay is a little effort to give Cython some type annotation or other this kind of “hints” in Python or near-Python syntax. In addition, Cython could talk to both C/C++ and CPython make it a good tools for writing Python extension module.

The project will be a step towards Cython’s full compatibility of Python. Full compatibility means one day you will be able to grab any piece of Python code, feed it to Cython and Cython will produce optimized C code for you. Just think about… a compiled Django?

However, let Cython directly translate your Python code to C will not give you too much benefits on performance since Cython cannot optimize the code without knowing the type of variables. That’s why Cython has its own keyword and syntax for declaring variables. Now, Python 3 comes with function annotations, combined with function/class decorators, they could do the job of providing type information perfectly. Thus, in this project, I will implement the feature of using Python 3 function annotation to provide type information for Cython.

Hopefully generator support will be implemented by other Cython developers in this summer. After that, it would be type inference and flow analysis to make Cython smarter. That will be another story.


May 10, 2010. Uncategorized. Leave a comment.