Terminology

Python is the programming language, while CPython (aka python.exe) is the default Python interpreter (that is written in C). Python is defined as both a compiled & interpreted language.


Marshalling refers to the serialization of Python objects so that they can be stored (as bytes) Freezing is to package Python scripts into a single executable


.pyc files contains the compiled Python byte code .pyd files are frozen Python modules (i.e. DLL files made using Python)

How CPython Works

https://tenthousandmeters.com/

Untitled

  1. Python source code .py gets compiled to Python byte code .pyc
  2. Byte code & library modules gets passed to the Python virtual machine
  3. Virtual machine interprets the byte code & executes it

Python Byte Code

File Format .pyc

https://nowave.it/python-bytecode-analysis-1.html

https://nowave.it/python-bytecode-analysis-1.html

Code Objects

https://late.am/post/2012/03/26/exploring-python-code-objects.html https://blog.svenskithesource.be/posts/code-objects

When we compile source code in Python, the result is a code object. These objects contain lots of metadata, and are especially useful in cases where it is difficult to recover the source code. Eventually, these marshalled objects will get passed to CPython as a PyCodeObject struct to be interpreted.