Multi-processing in Python; Process vs Pool

Nikhil Verma
5 min readFeb 18, 2020

You know my code runs more than one computation on same input. All these different computations provide me different kind of results and do not share any dependency on each other. But for the time being all of them run synchronously, i.e. one after the other. How could i reduce the time of my overall computation?

Lets Employee Parallel Processing

The solution to such a problem is Multi-processing. But hey some of you have heard of multi threading as well, cant I employ that here. Well, Threads uniquely run in the same unique memory heap where as Processes run in separate memory heaps. This makes sharing information harder with processes and object instances. One problem arises because threads use the same memory heap, multiple threads can write to the same location in the memory heap which is why the global interpreter lock(GIL) in CPython was created as a mutex to prevent it from happening.

What is global interpreter lock(GIL)

CPython is the reference(standard) implementation of the Python Programming Language. Written in C and Python, CPython is the default and most widely used implementation of the language. It can be defined as both an interpreter and a compiler as it compiles Python code into byte-code before interpreting it. A particular…

--

--

Nikhil Verma
Nikhil Verma

Written by Nikhil Verma

Knowledge shared is knowledge squared | My Portfolio https://lihkinverma.github.io/portfolio/ | My blogs are living document, updated as I receive comments

Responses (1)