1.安装Cython
pip intall Cython
2.在.py文件目录下创建setup.py
# 脚本文件
from distutils.core import setup
from Cython.Build import cythonize
setup(
name = 'Hello',
ext_modules = cythonize("xxxxxx.py"),
)
3.在cmd下运行,
python setup.py build_ext --inplace
在Windows下生成.pyd文件
4.假如pyd文件名为:“Test.cp37-win32.pyd”
在主程序中使用
import Test
即可对其引用。
参考文献
https://blog.csdn.net/wanzheng_96/article/details/103141273
https://blog.csdn.net/g6uqwseseo/article/details/71439453?locationNum=11&fps=1