Sobes.tech
Junior — Middle

During what type of multitasking does the system consume more resources?

sobes.tech AI

Answer from AI

In multitasking on Python, more system resources are consumed when using multiprocessing rather than multithreading.

The reason is that each process has its own address space and a copy of the Python interpreter, which requires more memory and OS resources. Meanwhile, threads in Python share memory and resources of the process, but due to the GIL (Global Interpreter Lock), they cannot effectively utilize multiple cores for CPU-bound tasks.

Thus:

  • Multiprocessing consumes more resources but is better for CPU-bound tasks.
  • Multithreading uses fewer resources and is suitable for I/O-bound tasks.

Example:

from multiprocessing import Process

def task():
    print('Working')

if __name__ == '__main__':
    p = Process(target=task)
    p.start()
    p.join()
During what type of multitasking does the system… - sobes.tech