Why Your Async Code Might Be Slower and How to Fix It
summary
Async can be slower when awaits run sequentially, synchronous libraries block the event loop, CPU work freezes everything, or hundreds of tiny coroutines add overhead. Examples: sequential fetches take 2s vs concurrent gather 1s; requests blocks but switching to aiohttp or aiofiles halves latency; offload CPU work with run_in_executor to threads or processes; prefer TaskGroup (Python 3.11) or create_task for per-task error handling; use semaphores, asyncio debug and linters like flake kit async.
AI-written summary · about
