python file types
.py file
.Py extension to file is python code source file, you can directly see the code executed by the python interpreter.
.pyc
.Pyc extension to file is the code for the source file of compiled files.
Its execution speed is faster than py file.
Simple compiler, not encrypted, decompile can get the source code.
.pyw
.pyw file and its essence is a qualitative .pyc file.
The difference is that the implementation of the program will appear .pyc file GUI console, the GUI program execution point .pyw not appear console.
.pyo
"Python -O source" Python source code can be compiled into .pyo file, but sometimes still have to adopt .pyc suffix, to run properly.
.pyo file is relatively .pyc terms, optimizing Python file compiled.
.The / so
You may disassemble, but not decompile.
.pyd file a non-Python, "write - compile" generated by other programming languages Python extension modules.
Cython can be individual based on the Python language Python modules compiled into .pyd or so file with the C language features. Essentially converted to C code sub pyd / so file.
Generate so / pyd file
- Installation easycython, currently supports only to python3.6. pypi address
pip install easycython
- The need to generate so / pyd files into pyx py file suffix.
Such as:pay.py
named:pay.pyx
- Using a command
easycython xxx.pyx
automatically generatedpyd(windows)
orso(linux)
. - Wherein the generated file name
hello.cpython-36m-x86_64-linux-gnu.so
middle portion removed, such ashello.so
.
Instructions
- Main.py create a new file.
import os
import sys
#将当前so所在的路径添加到sys.path, python是在sys.path路径中找模块的
sys.path.append(os.path.realpath('.'))
from hello import hello
hello()
pyd文件理论上也是一样的。