in Education by
I am trying to understand the advantages of multiprocessing over threading. I know that multiprocessing gets around the Global Interpreter Lock, but what other advantages are there, and can threading not do the same thing? Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
Multiprocessing:- The multiprocessing module uses a process that runs on separate memory space. Due to this, it is harder to share objects between process and multiprocessing. Pros:- Its code is usually straightforward. It takes advantage of multiple CPUs & cores Avoids GIL limitations for CPython Here we can interrupt/kill the Child processes. Python multiprocessing module has very useful abstractions with an interface much like threading. Cons:- IPC a little more complicated with more overhead (communication model vs. shared memory/objects) Larger memory footprint(it uses more amount of main memory space). Threading:- The threading module uses thread (A thread is an entity within a process that can be scheduled for execution. Also, it is the smallest unit of processing that can be performed in an Operating System). Since threads use the same memory space(amount of memory assigned to any program by CPU), precautions have to be there because both the threads will write to the same memory at the same time. For this, we have the global interpreter lock. Pros:- It is lightweight - low memory footprint(it uses less amount of main memory). As it has shared memory that makes access to one state from others is easy. It also allows you to easily make responsive UIs. Cons:- CPython - subject to the GIL. It is not interruptible/killable.

Related questions

0 votes
    Is it possible to terminate a running thread without setting/checking any flags/semaphores/etc.? Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    Currently, Google App Engine supports both Python & Java. Java support is less mature. However, Java seems to ... libraries, though. Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    (I'm using the pyprocessing module in this example, but replacing processing with multiprocessing should probably ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    (I'm using the pyprocessing module in this example, but replacing processing with multiprocessing should probably ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 7, 2022 in Education by JackTerrance
0 votes
    (I'm using the pyprocessing module in this example, but replacing processing with multiprocessing should probably ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 6, 2022 in Education by JackTerrance
0 votes
    Hey there Stack Overflow. I'm trying to build a testing script that should mix outputting changing ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    What is the difference between the two? It seems that both create new columns, in which their number is equal to ... they are in. Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    I understand that Batch Normalisation helps in faster training by turning the activation towards unit Gaussian ... normalization. Select the correct answer from above options...
asked Jan 29, 2022 in Education by JackTerrance
0 votes
    In Python 2.6, the str.format() has been introduced and has a slightly different syntax than existing % operator. ... %s" % some_info) Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    What will be the output of the following Python function? min(max(False,-3,-4), 2,7) a) -4 b) -3 c) 2 d) False...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    I can use vi{ and va{ to select C++ code blocks. It helps me a lot when I need to yank ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    I have two list that I combine into a single list. Later I want to make a copy of this list so ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 27, 2022 in Education by JackTerrance
0 votes
    I have an object with an attribute that is a list. For example: obj.a = [3, 4, 5] I ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    I'm curious about manipulating time in Python. I can get the (last modified) age of a file using ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    I have an object with an attribute that is a list. For example: obj.a = [3, 4, 5] I ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 30, 2022 in Education by JackTerrance
...