[Cython] Improving compile times for Cython extensions with C sources

Robert Bradshaw robertwb at gmail.com
Mon Sep 16 22:12:00 CEST 2013


On Mon, Sep 16, 2013 at 11:48 AM, Wes McKinney <wesmckinn at gmail.com> wrote:
> I haven't been able to find an easy answer to this question, but here is my
> problem:
>
> Cython file: extension.pyx
> Declarations / C imports: extension.pxd
> C dependencies:
> a.c
> b.c
> c.c
>
> These are all compiled together to produce extension.so.
>
> The problem is, when I modify extension.pyx, all 4 C files are recompiled,
> even if the 3 straight C files are untouched.
>
> Any way to fix the build system to not do this? Seems that the .o files from
> the C dependencies could be easily reused.

Cython compiles the .pyx file to a .c file; distutils takes over from
there. I'm not aware of any way to do this (short of making a+b+c into
a shared library) but perhaps someone on the distutils lists would
have some ideas.

You could also look at using ccache.

- Robert


More information about the cython-devel mailing list