How to increase the speed of your python code?

Divyanshu Tiwari
1 min readJan 16, 2021

If you are a python coder you might be aware of the speed issue, it’s not that much to be noticed but when it comes to data science and machine learning, two most useful application of python programming language, then it really is difficult for one to sit and watch the program to get stuck. So without wasting a second let’s discuss a easy and conceptual way of increasing the speed.

This concept is very easy and useful, but is ignored as well, Multiprocessing, the same concept where you utilise each processor of your system, for multitasking these processors are used in a synchronised way to perform a certain number of task in fraction of time.

For doing so, import multiprocessing module in your python program, before doing so, check whether the multiprocessing is installed or not. For checking , type this in your command prompt:

pip list

Check whether multiprocessing appeared on the list, if it is not type the following command :

pip install multiprocessing

After installation use it in various machine learning and data science programs, a simple use of it mentioned below:

Although I personally recommend to read the documentation of multiprocessing module, and also study the risk of deadlock while performing multitasking.

--

--