[Cython] Cython <> pythran collaboration

Robert Bradshaw robertwb at gmail.com
Tue Dec 9 18:02:19 CET 2014


On Mon, Dec 8, 2014 at 11:52 AM, serge Guelton
<serge.guelton at enst-bretagne.fr> wrote:
> Hi Cython dev,
>
> I am one of the two core developers of the Pythran[0] compiler.
> We are planning to start a project where Cython would delegate the
> generation of optimized (i.e. parallel / vectorized / without temporary
> arrays) numpy expression when it finds one, instead of calling the
> native API. Something like the following meaningless example:
>
>     import numpy as np
>     cimport numpy as np
>
>     def play_with_arrays(np.ndarray arr):
>         cdef int N = arr.shape[0]
>         cdef np.ndarray other_arr = np.empty([N], dtype=np.int)
>
>         other_arr = arr ** 2 + 1 # pythran would handle this
>
>         for i in range(N):
>             other_arr[i] /=  2 # cython would handle this
>
>         return  other_arr
>
> Everything would live in a pyx file and it should be transparent to a
> cython user. Cython would drive the compilation process, using pythran
> as a numpy expression optimizer.
>
> Does that look feasible / appealing to you?
>
> [0] http://pythonhosted.org/pythran/

Yes, that would be very cool; efficient array operations (including
broadcasting) without intermediates is something we've long wanted to
have.

- Robert


More information about the cython-devel mailing list