python pyd文件生成方法[1]
准备两个文件
hello.pyx
setup. py
执行命令:
setup.py build_ext --inplace
产生的文件
然后可以
import hello
hello.cp38-win_amd64.pyd
就是一个模块。
如何使用这个模块
就和平时使用其他模块一样
import math
import numpy as np
import hello
这个模块是自己定义的模块。
要放到合适的路径,才能引用到。
总结:
自己生成了一个模块,
这个模块不是.py文件
而是.pyd文件,这个文件无法用记事本查看的,使用者无法查看模块源码。
对比之前的py文件,可以看到源码。
.py 生成 .c
.pyx 生成.c
.c 生成.pyd
反过来可以吗?
.pyd 生成.c
.c 生成.py
正反,可以?
参考
- ^tutorial https://cython.readthedocs.io/en/latest/src/tutorial/cython_tutorial.html