Introduction
In most Machine Learning jobs, you won’t do research on improving some model architecture or designing a brand new loss function. More often than not you should utilize what already exists and adapt it to your use case. So it is rather essential to optimize your project when it comes to architectural design and implementation. Every little thing starts from there: you would like optimal code, that’s clean, reusable and runs as fast as possible. Threading is a Python built-in native library that folks don’t use as often as they need to.
About Threads
Threads are a way for a program to split itself into two or more concurrently (or pseudo-simultaneously) running tasks … typically, a thread is contained inside a process and different threads in the identical process share the identical resources.
In this text, we don’t discuss multiprocessing, however the Python library for multiprocessing works very similarly to the multithreading one. Generally:
- Multithreading is great for I/O bounds tasks, like calling an API inside a for loops
- Multiprocessing is used for CPU-bound tasks, like…