python 生成 pyd 隐藏python 代码
# Calculate.py
class Calculate:
def add(self, x, y):
return x + y
# setup.py
from setuptools import setup
from Cython.Build import cythonize
setup(
name="demo",
ext_modules=cythonize("Calculate.py")
)
python setup.py install
import demo
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
calculate = demo.Calculate()
ret = calculate.add(11, 111)
print(ret)

浙公网安备 33010602011771号