[Cython] [Desired feature] Process .pxd before .py

Stefan Behnel stefan_ml at behnel.de
Thu Aug 28 16:57:44 CEST 2014


Alexandru Ionut Grama schrieb am 26.08.2014 um 17:45:
> I've start to use cython in order to use call some API modules written in
> python from C/C++. Those modules written in python must remain untouched,
> and all .py files should be "decorated" with their counterpart .pxd files.
> I would like to mark as public some API functions from .py files, following
> the indications from http://docs.cython.org/src/tutorial/pxd_files.html.
> I've started to write a little example:
> 
> suma_alex.py:
> def suma_Alex(a,b):
>         return a+b
> 
> suma_alex.pxd:
> cdef public int suma_Alex(int a,int b)
> 
> 
> The combination of those two files should turn into something like this for
> the compiler:
> 
> cdef public int suma_Alex(int a,int b):
>       return a+b
> 
> On generated .h file I should obtain a function prototype like this:
> __PYX_EXTERN_C DL_IMPORT(int) suma_Alex(int, int);
> 
> Instead of that, I obtain a prototype like this:
> __PYX_EXTERN_C DL_IMPORT(int) __pyx_f_10suma_alex_suma_Alex(int, int);

Looks like a bug to me. There is a step in the pipeline that merges the
.pxd file declarations into those found in the main source file. Either the
"public" modifier is not properly copied over or the cname needs to be
updated when merging in the override declarations.

Stefan



More information about the cython-devel mailing list