CPU-bound vs I/O-bound — multiprocessing and asyncio
Picture two workloads. In the first, you fire two hundred small HTTP requests and most of the runtime is thumb-twiddling while packets return—your CPU is bored. In the second, you grind through millions of Python loop iterations with no I/O—the cores are busy, and adding more waiting does not help.
Concurrency is about where time goes. For heavy pure-Python CPU work, the GIL keeps one interpreter from using threads as true parallel compute, so multiprocessing (separate processes) is the usual path to multiple cores. For I/O-bound storms of network or disk waits, asyncio with an async HTTP stack like aiohttp overlaps many waits in one thread instead of spawning a process per URL.
The cautionary beat: parallelizing tiny tasks can cost more in scheduling than you gain, and dropping a blocking call into an asyncio loop stalls the whole orchestra unless you offload with run_in_executor.
Contrast this with synchronous requests-style scripts in requests, JSON APIs, and robust fetching, where calls block until each response returns. Intro: [1].
Sources
Tasks
Card Info
- Topic: Data Science Praktikum
- Difficulty: Beginner
- Completed: 1 users