In Python, convert py file to pyd file

1. Source:

  1. During the development process, we often encounter the need to encrypt or speed up the running speed. At this time, we can convert the py file into a pyd file to speed up the running speed.

2. Steps

  1. Create the setup.py file and edit the following content
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# here put the import lib
from distutils.core import setup
from Cython.Build import cythonize

setup(ext_modules=cythonize(["要转换的py文件名.py"]))
  1. Run the following command to generate a pyd file
python setup.py build_ext --inplace

Guess you like

Origin blog.csdn.net/zhuan_long/article/details/133386485