⚙️Packaging, Bytecode & CPython Internals
pyproject.toml, how code becomes bytecode, and the dis module.
§ 1Packaging
Modern projects use pyproject.toml to declare name, version, dependencies and build backend (hatchling, setuptools, poetry). python -m build makes a wheel; twine uploads to PyPI.
§ 2Source → bytecode
CPython compiles .py to bytecode (cached in __pycache__/*.pyc) and the interpreter loop executes it. dis.dis(fn) shows the instructions.
§ 3Interning & small ints
Ints -5..256 and many short strings are cached, so `is` may surprise you — another reason to use == for values.
§ 4Python 3.11+ speedups
The specializing adaptive interpreter rewrites hot bytecode for common types; 3.13 adds an experimental free-threaded (no-GIL) build and a JIT.
Worked example
1import dis23def add(a, b):4 return a + b56dis.dis(add)7print(add.__code__.co_varnames)8x = 256; y = 2569print(x is y)Try it live · Python runs in your browser
Checkpoint quiz
Lesson test
Take an 8-question test on “Packaging, Bytecode & CPython Internals” — concepts, output prediction, bug spotting and interview questions.