Multiprocessing in Python — Python Technical Interview Questions & Answers

Multiprocessing in Python

Multiprocessing in Python

  • multiprocessing starts separate processes — real parallel CPU. threading shares memory, good for I/O waits. GIL limits CPU threads in CPython.
  • Fresher line: I/O bound → threads. CPU bound → processes. Don’t claim threads make matrix multiply 8× faster on CPython.
  • Multiprocessing in Python — output: CPUs and your real core count. Processes use separate memory; threads share memory.

Technical Interview Tip: I/O vs CPU + GIL in one sentence.

Code Examples for Multiprocessing in Python

Example

# Multiprocessing in Python
from multiprocessing import cpu_count
print("CPUs", cpu_count())

Multiprocessing in Python — output: CPUs and your real core count. Processes use separate memory; threads share memory.

How to Explain Multiprocessing in Python to an Interviewer

Explain Multiprocessing as if you are teaching a junior — definition, then one tiny script.

Process : separate memory, CPU. Thread : shared memory, I/O.

What does the example print, and why?

Multiprocessing in Python — output: CPUs and your real core count

What mistake do freshers make with Multiprocessing?

GIL on CPU threads.