GSoC Week #8 & #9

I was a bit unwell in the last week so the progress is a bit slow and I have to merge the two weeks’ reports…

The test mechanism for .py test cases under pure Python is done. Renaming the pure.pyx test case to reveals some issues in the shadow module, and I got them fixed. The decorators for cdef class/function and cpdef function, @cython.cclass, @cython. cfunc and @cython.ccall respectively, are done.

Due to the limitation of Python, the shadow mode, which is to simulate Cython’s pure Python syntax under Python interpreter, cannot fully support all the things that Cython supported. The most obvious one is you cannot use positional argument to initialize a struct or union. For example, assume we declared a struct:

MyStruct = cython.struct(, bar=cython.bint)


s1 = MyStruct(1, True) # this is valid Cython but cannot work in shadow mode
s2 = MyStruct(foo=1, bar=True) # this works in both mode

This is due to when we calling cython.struct with keyword arguments, the passed in **kwds dict is not ordered.

The decorators that replaces the cdef syntax should works well now. In addition to use them as decorator, I also make them able to be used in with statement, it would be useful when you are going to define several cdef function in a batch:

with cython.cfunc:
    def foo():
    def bar(x):
        return x

There’s no extra work to make them working in ‘with’ statement, thanks to Cython’s flexible directive system. Though, I’m feeling a bit strange to treat these decorators as directive. :p

July 30, 2010. Uncategorized. Leave a comment.

GSoC Week #7

Last week Craig reviewed two of my patches. The reviews are very careful and covered almost every corner of my code. It makes me think more about the problem and solution. Revised patches are submitted. Hopefully they will be better.

I also started to implement a test mechanism for Cython’s pure Python mode. The problem is Cython’s current test suite compiles all the tests, thus the, which is a module to fake the various Cython declarators under pure Python, is not covered by the test suite. So I modified the test runner to additionally run the test cases that with “.py” extension under pure Python interpreter without compilation through Cython. This then revealed some problem and behavior divergence between the and actual Cython syntax. I’m going to fix it.

July 14, 2010. Uncategorized. Leave a comment.

GSoC Week #6

Not so much things have been done in the last week. The patches have been finally sent to my mentor Craig for review. For those who are interested, I just found there is a way to list these issues on the Rietveld Code Review site:

Please feel free to give comments! 🙂

There are some interesting discussions about Cython’s C++ support. Indeed, the support is not very comprehensive yet. During my previous usage of it, I encountered some problem and have did some monkey patch to fix them. Take this as a chance, I posted the patches and issues to trac.

This week would be much more productive. Craig started to review my patches and has given a lot of useful comments. So I’ll refine the code.

July 7, 2010. Uncategorized. Leave a comment.