[Cython] Support for .pxi files

Robert Bradshaw robertwb at math.washington.edu
Sun Mar 13 09:09:19 EDT 2016


On Fri, Mar 11, 2016 at 1:58 AM, Jeroen Demeyer <jdemeyer at cage.ugent.be> wrote:
> On 2016-03-11 10:34, Robert Bradshaw wrote:
>>
>> On a more pragmatic note, includes add complexities to dependency
>> tracking
>
>
> Because you *intentionally* make things complicated. The refused pull
> request 392 could actually make dependency checking simpler by treating .pxd
> and .pxi files more alike.

We can't because of how relative imports are resolved in included
files (they're relative to the includer). This goes way back to the
beginning, and would be non-trivial to change.

>> Every single case I can think of would be better done by using
>> cimports or preprocessing via a proper templating (or at least
>> preprocessing) utility.
>
>
> The difference is that such preprocessing will be external to Cython, which
> will make the build process more complex. You need to figure out what to do
> with the files generated by the templating and you need to get dependency
> checking right... I must admit that I am quite happy that Cython solves
> these problems for me.
>
> Do you have an example of a project which actually uses such
> templating/preprocessing?

Sage (e.g. fast callables).

We should make support for this better, e.g. one specify a Python
callable or a command line (not sure about cross-platform dependence
on that last one) to use for preprocessing right in the source file.
However, given that module lists are code, it doesn't seem that hard
to generate sources programmatically right before calling cythonize,
adding another intermediate into the source -> .so chain.


More information about the cython-devel mailing list