CPython Performance Profiling and Acceleration

Parent: Programming Languages · researched 2026-06-01T05:19:59.013Z· 18 sources · 8 concepts · skill cpython-performance-profiling

> Hub reference under programming-languages. Created via /dr (2026-06-01). Sources: official Python docs (profile/pstats), project docs/GitHub (py-spy, Scalene, memray, pytest-memray, Cython), the Sca

CPython Performance Profiling and Acceleration

1. Deterministic profiling — cProfile / profile / pstats

2. Statistical / sampling profilers — py-spy, Austin

3. Scalene — line-level CPU+GPU+memory, native separation

4. memray — allocation-level memory profiling (Bloomberg)

5. line_profiler / kernprof — per-line CPU

6. Benchmarking — measure the fix, not the noise

7. Flame-graph interpretation

8. The native-acceleration ladder (native is the LAST resort)

Anti-patterns and gotchas

References (2026-06-01)

Children

Frontier under this node: Benchmarking (timeit, pyperf, pytest-benchmark, CI perf budgets), Deterministic profiling (cProfile/profile + pstats, SortKey, ncalls/tottime/cumtime, calibration, snakeviz/gprof2dot), Flame-graph interpretation (self vs cumulative, speedscope views), Native-acceleration ladder (Cython cdef/typed-memoryviews/nogil/prange, Numba @njit, mypyc, PyO3/Rust, ctypes/cffi), Scalene (line-level CPU+GPU+memory, Python-vs-native-vs-system separation, copy-volume, AI suggestions), Statistical/sampling profilers (py-spy record/top/dump, --native/--gil/--subprocesses, speedscope/flamegraph, Austin), line_profiler/kernprof per-line CPU and py-heat, memray (Bloomberg allocation profiler, native tracking, flamegraph/table/tree, live mode, leaks/temporal, pytest-memray)

← the whole tree · 3D view· how to read this page