CPython's global interpreter lock lets only one thread run Python bytecode at a time, so threads cannot use several cores for CPU-bound Python code, though they work well for I/O-bound work because the lock is released while waiting on I/O.
Processes have separate interpreters and address spaces, so they run in parallel on different cores, at the cost of memory duplication and inter-process communication (pickling, shared memory).
asyncio uses a single-threaded event loop (built on epoll) for many concurrent I/O tasks, such as LLM API calls.
from concurrent.futures import ProcessPoolExecutor
def cpu_heavy(x):
return sum(i * i for i in range(x))
if __name__ == "__main__":
with ProcessPoolExecutor() as ex: # one worker process per core by default
results = list(ex.map(cpu_heavy, [10_000_000] * 8))