https://moonlet.gitbooks.io/cython-document-zh_cn/content/ch1-basic_tutorial.htmlhtml
add_num.pyx文件python
def add_nums(ls): total = 0. for l in ls: total += l return total
set_up.pylinux
from distutils.core import setup from Cython.Build import cythonize setup( ext_modules = cythonize("add_num.pyx") )
運行git
python setup.py build_ext --inplace
linux上會生成add_num.so文件。
能夠刪除add_num.pyx文件。
以後能夠直接調用
import add_num ls = [4,5,6,29] print(add_num.add_nums(ls))