I have been trying to understand how cython really works. Very first, I have written test.pyx file containing,
import numpy as np
a=2;b=3;
np.sum(a,b)
np.subtract(a,b)
I wrap this code in setup.py file,
from distutils.core import setup
from Cython.Build import cythonize
setup(ext_modules = cythonize("test.pyx"))
Later I run test.pyx from command line as,
python setup.py build_ext --inplace
This command generates test.c code. The generated C code is really big and difficult to understand. Now, I just like to know where can I find implementation of np.sum(a,b) . If i am successful to get the Python to C translated sum function can I use it as an independent function in other C codes. Will this function has some dependencies that I have to copy along with it.
Looking forward for the good answers.
Thank you guys for your suggestion. After having a look at html file what i see looks like,
+06: import numpy as np
__pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
This means it is calling __pyx_n_s_numpy module. How can a C compiler runs this module. I think implementation of this module is in .py format.