Python

Notes on the Python programming language — testing, async, type hints, and practical patterns.

Pre-allocated lists in Python

Understand CPython list memory allocation: how lists store pointer references, grow dynamically, and when pre-allocation with [None]*n helps.

Self type in Python

Use Python's Self type from PEP 673 to annotate methods returning class instances, eliminating complex forward references and TypeVars.