Why Python Loops Are "Slow": A Gentle Introduction to Interpretation, Bytecode, and Fast Code
summary
Explains why Python loop overhead comes from dynamic typing, per‑iteration interpretation, and poor branch prediction, using a Mac M1 benchmark: a naive Python loop takes 109 seconds versus NumPy 3.4s, Numba 4.1s, and Polars 15s. Shows how NumPy uses static dtypes and SIMD, Numba JITs to LLVM and auto‑vectorizes, and Polars compiles to Rust with columnar vectorized execution, so actual speedups come from static typing, vectorization, and CPU‑level optimizations.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 2:59When code is too slow
- 4:04How computers process code
- 6:35Python’s execution process
- 9:22Reasons loops are slow
- 13:15Python vs optimized tools
- 14:45NumPy for performance
- 16:51Numba JIT compilation
- 20:01Polars for processing
- 23:11Performance vs readability
- 25:15Q&A
related talks
33mWhy is Python slow?
54mWhy Python Is So Slow
26mWhy are Python and Ruby slow?
35mVectorization: How slow Python runs fast code
36mHow to Optimize your Python Program for Slowness
01h 12mFurious & Fast Python 7: Writing Fast Python Code
40mSpeed Without Drag
59mMyths and fairy tales around Python performance
