我有以下 Cython 的内联函数
cpdef inline int c_rate2recs_2(int maxNN,int idx):
cdef int out=idx%maxNN
return out
然而,这转化为
/*
* return out
*
* cpdef inline int c_rate2recs_2(int maxNN,int idx): # <<<<<<<<<<<<<<
* cdef int out=idx%maxNN
* return out
*/
static PyObject *__pyx_pw_6kmc_cy_5c_rate2recs_2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static CYTHON_INLINE int __pyx_f_6kmc_cy_c_rate2recs_2(int __pyx_v_maxNN, int __pyx_v_idx, CYTHON_UNUSED int __pyx_skip_dispatch) {
int __pyx_v_out;
int __pyx_r;
__Pyx_TraceDeclarations
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("c_rate2recs_2", 0);
__Pyx_TraceCall("c_rate2recs_2", __pyx_f[0], 984);
/*
* return out
*
* cpdef inline int c_rate2recs_2(int maxNN,int idx): # <<<<<<<<<<<<<<
* cdef int out=idx%maxNN
* return out
*/
static PyObject *__pyx_pf_6kmc_cy_4c_rate2recs_2(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_maxNN, int __pyx_v_idx) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("c_rate2recs_2", 0);
__Pyx_TraceCall("c_rate2recs_2", __pyx_f[0], 984);
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = PyInt_FromLong(__pyx_f_6kmc_cy_c_rate2recs_2(__pyx_v_maxNN, __pyx_v_idx, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("kmc_cy.c_rate2recs_2", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
由于我是 cython 业务的新手,我想知道如何摆脱大多数 Python 命令(cython -a
将此内联标记为与纯 C 相去甚远)。