Down to the deep of the interpreter: we will explore the internal format of code in Python, how it evolved, and how it is stored in pyc files. We’ll see how to disassemble it, and how to write functions in raw bytecode in runtime.
Bytecode, the internal language of instructions used by the interpreter is something that perhaps most Python developers have heard about, but few have dug into. This talk will try to explain the idea behind bytecode and how it works. I will also try to map its evolution over Python versions.
We will see who to extract bytecode from functions - with dis
module, and from .pyc files (and what is the idea of __pycache__
directories). Then the other way around: we’ll explore the possibilities of building new functions with raw bytes in runtime.