Loading…
A short voice session: one question, one follow-up, then instant feedback — up to 5 minutes.
Measure first: use tracing and metrics to see where request time goes, profile the hot path with a sampling profiler such as py-spy, separate I/O waits from CPU work, and fix the biggest cost, which is usually queries or external calls, before micro-optimizing Python.
Start with observability: latency percentiles, distributed traces and database timing show whether time is spent in the database, external services, serialization or Python code. For CPU work, a sampling profiler like py-spy can attach to a running process with low overhead and produce flame graphs, while cProfile and line_profiler help locally. Typical findings are N+1 queries, missing indexes, sequential external calls that could run concurrently, large JSON serialization, or algorithmic problems like repeated linear searches. Fix the largest contributor, verify with the same measurement, and add a benchmark or alert. Only after that consider caching, better data structures, vectorized libraries or native extensions.