Profiling only Python’s main thread can miss the real bottleneck
Simon Willison’s Python 3.15 profiling experiment found that 95.1% of sampled stacks in a busy web-edit workload came from an AnyIO worker thread. A main-thread-only profile would have missed them. Line-ending preservation appeared in 64.8% of recorded CPU stacks. The published flame graph illustrates why profiling configuration matters; these percentages describe that generated workload, not all uses of the app.
Simon Willison · Oct 12, 2026
Why it matters
A convincing-looking profile can point you in the wrong direction if it omits the threads doing the work.
More context
Try all-thread sampling on a representative workload using Python 3.15’s profiling.sampling module. The author used an agent to generate this investigation and later linked optimizations in web-edit 0.1a1.
Keep in mind
Sampling frequency and workload selection affect interpretation; presence in sampled stacks is not a measured end-to-end speedup.
Original read