Python Performance Investigation by Example
summary
A brute force Python solution that simulates the firewall runs through 3.8 million steps and takes about 1,012 minutes, then a math rewrite that computes scanner positions removes state copying and drops runtime to six seconds — a factor of 100 improvement. Running the same code on PyPy and using compilers / JITs like numba and Cython pushes times into subsecond and millisecond territory, showing profiling, targeted refactor, and selective compilation actually work.
AI-written summary · about
chapters (29)
- 0:00Introduction
- 0:24Meet Matt Davis
- 0:53Performance
- 1:40Scientific Process
- 2:09Advent of Code
- 2:55Firewall Crossing
- 3:41Counter Time Steps
- 4:50Code Outline
- 5:18Scanner Class
- 5:44Scanner Dictionary
- 6:06Clock Crossing
- 7:12Catching Clock Crossing
- 7:50Did it work
- 8:12Pause
- 9:18Profiling
- 10:45C Profile
- 11:24Stats
- 12:07Total Time
- 12:49SnakeVis
- 17:09Reframe
- 17:32Caught Crossing
- 18:05Fine Start
- 20:19PiPI
- 21:51Number
- 24:16Catching crossing
- 24:38Counting time
- 25:24Scythe
- 27:06Safety
- 30:11Conclusion
related talks
33mWhy is Python slow?
01h 31mDebugging and profiling techniques
19mPython - best practices
36mHow to Optimize your Python Program for Slowness
22mExperiences making CPU-bound tasks run much faster
30mWrite faster Python! Common performance anti patterns
57mPython and PyPy performance (not) for dummies
32mProfiling at the speed of light
