Given that certain extensions .pyc
, .pyd
, .pyo
, and .py
exist in Python , what are the main differences between them? What does each one represent?
Given that certain extensions .pyc
, .pyd
, .pyo
, and .py
exist in Python , what are the main differences between them? What does each one represent?
.py
: usually the input source code you wrote. .pyc
: is the bytecode compiled. If you import a module, Python will build a *.pyc
file that contains bytecode to make it easier and faster .pyo
: is a * .pyc file that was created with optimizations enabled (-O) .pyd
: is basically a Windows DLL file . .pyw
: Python script for Windows. It runs with pythonw.exe
.pyx
: Cython font to be converted to C / C ++ .pxd
: Cython script which is equivalent to a C / C ++ header .pxi
: MyPy stub
.pyi
: stub file ( PEP 484 ) .pyz
: Python script file ( PEP 441 ); Contains scripts compressed Python (ZIP) in binary form after the Python standard script header .pywz
: Python script file for MS-Windows ( PEP 441 ); Contains scripts compressed Python (ZIP) in binary form after the Python standard script header Fonts in Bill Lynch SO Answers and Devyn Collier Johnson .
.py
is usually the code written by yourself.
.pyc
is compiled binary code. If you import a module, Python will generate a * .pyc file that contains the binary to facilitate (and be faster) to import the same module again.
.pyo
equal to file .pyc
but created when optimizations (-0) were linked.
.pyd
is basically a windows dll file (more info HERE )
If you want more infos about the difference between .pyo and .pyd, check out here
Source: SO gringo