Level Up Your Coding Skills with Python Threading

-

Photo by Sonika Agarwal on Unsplash

Learn the best way to use queues, daemon threads, and events in a Machine Learning project

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…
ASK DUKE

What are your thoughts on this topic?
Let us know in the comments below.

0 0 votes
Article Rating
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Share this article

Recent posts

0
Would love your thoughts, please comment.x
()
x