Why processes rather than threads, and how many workers?
This follow-up was reported once for the image pipeline (1 report), and another candidate sped theirs up with a ProcessPoolExecutor (1 report). A 2024 candidate comment also describes an Anthropic crawler question that asked for a batch version with processes or threads, in C++ (1 report).
Answer with the measurement, not the rule:
- The transforms are Python loops over values, so the work holds the GIL. 4 threads took 0.730 s against 0.690 s alone, and 4 processes took 0.284 s.
- Then the costs: start-up, about 0.1 s for 4 workers here, and pickling each item both ways. That's why the steps are names and numbers, and every function is top level.
- Then the count: about one process per core for computing, more threads for waiting.
- Then when you'd skip processes: items too small to be worth sending, or a library like NumPy or PIL whose C code may release the GIL, so threads already scale.
If they ask about Python with no GIL: the free-threaded build is separate and optional. It's officially supported since 3.14 but isn't the default. On it, threads can run Python code in parallel, so you'd measure there before you choose.
What they're listening for: CPU-bound (computing) against I/O-bound (waiting), said before they ask, and what has to be picklable.