<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: AinaJ</title>
    <description>The latest articles on DEV Community by AinaJ (@aina_j).</description>
    <link>https://dev.to/aina_j</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F103842%2Fd7b1235a-3e94-4d66-bc07-e4df4d315637.jpg</url>
      <title>DEV Community: AinaJ</title>
      <link>https://dev.to/aina_j</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aina_j"/>
    <language>en</language>
    <item>
      <title>raProMo: The Free Promotion Hub in Madagascar</title>
      <dc:creator>AinaJ</dc:creator>
      <pubDate>Sun, 04 Jan 2026 19:42:12 +0000</pubDate>
      <link>https://dev.to/aina_j/rapromo-the-free-promotion-hub-in-madagascar-375p</link>
      <guid>https://dev.to/aina_j/rapromo-the-free-promotion-hub-in-madagascar-375p</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/mux-2025-12-03"&gt;DEV's Worldwide Show and Tell Challenge Presented by Mux&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🛠️​ What I Built
&lt;/h2&gt;

&lt;p&gt;I built a 100% free web application where everyone can show or view promotions all around Madagascar.&lt;br&gt;
It's a kind of e-commerce website, 100% free for buyers and sellers.&lt;br&gt;
A seller can have an online store and show their products or promotions.&lt;br&gt;
The buyer can make an order.&lt;/p&gt;
&lt;h2&gt;
  
  
  📽️​ My Pitch Video
&lt;/h2&gt;



&lt;p&gt;Enjoy the view of Madagascar Street...&lt;br&gt;


&lt;iframe src="https://player.mux.com/uH4AVe1orZ4ccULQC1wOIM8zrgG32VGxDX86zMM28Ic" width="710" height="399"&gt;
&lt;/iframe&gt;



&lt;/p&gt;

&lt;h2&gt;
  
  
  🎬​ Demo
&lt;/h2&gt;

&lt;p&gt;Visit &lt;a href="https://rapromo.mg" rel="noopener noreferrer"&gt;https://rapromo.mg&lt;/a&gt; &lt;br&gt;
You can see the available promotions in Madagascar now, and stores with promotions.&lt;br&gt;
Create an account if you want to set up a store and add some products.&lt;br&gt;
Tutorials are available on YouTube: &lt;a href="https://www.youtube.com/@Rapromo_mg" rel="noopener noreferrer"&gt;@Rapromo_mg&lt;/a&gt;&lt;br&gt;
There is also much information on the Facebook page &lt;a href="https://web.facebook.com/profile.php?id=61577363133435&amp;amp;_rdc=1&amp;amp;_rdr#" rel="noopener noreferrer"&gt;Rapromo&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  📜 The Story Behind It
&lt;/h2&gt;

&lt;p&gt;This is how rapromo was born and what makes it special.&lt;/p&gt;

&lt;h3&gt;
  
  
  💡 The day when the idea comes
&lt;/h3&gt;

&lt;p&gt;One day I was on the bus and saw many stores that showed "promotion" on their front doors. &lt;br&gt;
If I never pass near the store, I will never notice that there is a discount in the store.&lt;br&gt;
Then I wonder how people can know that there is a promotion somewhere without taking the time to move. &lt;br&gt;
So what if we put these informations online so people around Madagascar can see them, and so they can visit the store after having the information or make an order directly online.&lt;br&gt;
Then rapromo.mg was born, with the idea to make promotions information available online.&lt;/p&gt;

&lt;h3&gt;
  
  
  ✏️​ The name "rapromo"
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;ra&lt;/strong&gt;: Because Malagasy names generally start with "Ra"&lt;br&gt;
&lt;strong&gt;promo&lt;/strong&gt;: Because the main goal is to show promotional information, we just take "promo" from "promotion".&lt;/p&gt;

&lt;h3&gt;
  
  
  📝​ The principle
&lt;/h3&gt;

&lt;p&gt;Rapromo &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;is 100% free: because we want everybody to be able to use it. Money should not be a brake to stop people from using it. &lt;/li&gt;
&lt;li&gt;No pub: because we believe that everyone using rapromo should be equal. Everyone should have the same visibility. There are no ads to ensure fairness and avoid favoritism.&lt;/li&gt;
&lt;li&gt;With respect of privacy: Users’ personal information is neither used nor sold, honoring everyone’s privacy.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🌻​ What makes it special
&lt;/h3&gt;

&lt;p&gt;In Madagascar, the land of "moramora" (cheap in English), internet access is still a luxury. There is also a big gap between classes.&lt;br&gt;
Rapromo tries to give a world where Malagasy people can show and discover cheap products (moramora) in the way that everyone has the same right and can access the same information.&lt;br&gt;
It's free, and we only accept donations. Like the "buy me a coffee" we have "rakitra".&lt;/p&gt;

&lt;h2&gt;
  
  
  👩🏻‍💻 Technical Highlights
&lt;/h2&gt;

&lt;p&gt;Rapromo is written principally with Python and the Django framework.&lt;br&gt;
We use MariaDB to store data. &lt;br&gt;
For now it's deployed in a Docker-Swarm environment and has Traefik as a reverse proxy.&lt;br&gt;
We plan to have a mobile application for buyers.&lt;/p&gt;

&lt;h3&gt;
  
  
  🚀 Use of Mux
&lt;/h3&gt;

&lt;p&gt;Mux is used to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Host the pitch video in this post and also on &lt;a href="https://rapromo.mg/infos/" rel="noopener noreferrer"&gt;rapromo.mg&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Deliver fast, high-quality playback&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Discover and use rapromo on &lt;a href="https://rapromo.mg" rel="noopener noreferrer"&gt;https://rapromo.mg&lt;/a&gt;&lt;br&gt;
Follow us on &lt;a href="https://web.facebook.com/profile.php?id=61577363133435&amp;amp;_rdc=1&amp;amp;_rdr#" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for your time.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>muxchallenge</category>
      <category>showandtell</category>
      <category>video</category>
    </item>
    <item>
      <title>Does someone here succeed in the canonical recruitment process?</title>
      <dc:creator>AinaJ</dc:creator>
      <pubDate>Fri, 12 Dec 2025 18:15:00 +0000</pubDate>
      <link>https://dev.to/aina_j/does-someone-here-succeed-in-the-canonical-recruitment-process-4o9i</link>
      <guid>https://dev.to/aina_j/does-someone-here-succeed-in-the-canonical-recruitment-process-4o9i</guid>
      <description>&lt;p&gt;I'm a lead senior Python developer with a range of skills in system and network administration.&lt;br&gt;
There was a time when I applied for a dev position at Canonical, but the process was long and sometimes had nothing to do with software or teamwork skills. &lt;br&gt;
Of course, I fail many times.&lt;br&gt;
I practically understand that when recruiting, you search for a talented guy who can work with people, as I also do many parts of recruiting.&lt;/p&gt;

&lt;p&gt;I'm curious if there is someone here who succeeded in the canonical recruitment process and got the job?&lt;/p&gt;

&lt;p&gt;If yes, can you share how did you do and from which continent did you succeeded? &lt;/p&gt;

</description>
      <category>recruiting</category>
    </item>
    <item>
      <title>What satisfy you when you finish your day as a developer</title>
      <dc:creator>AinaJ</dc:creator>
      <pubDate>Tue, 22 Feb 2022 09:37:34 +0000</pubDate>
      <link>https://dev.to/aina_j/what-satisfy-you-when-you-finish-your-day-as-a-developer-3od</link>
      <guid>https://dev.to/aina_j/what-satisfy-you-when-you-finish-your-day-as-a-developer-3od</guid>
      <description>&lt;p&gt;One day I fall on a quote from Steve Jobs: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Being the richest man in the cemetery doesn't matter to me. Going to bed at night saying we've done something wonderfull... that's what matters to me". &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This makes me questioning about myself, So as a developer what satisfy me when I go back home after work?&lt;/p&gt;

&lt;p&gt;I work as a software developer. I generally write Python code for back-end, but there is also time that I switch to front-end.&lt;br&gt;
For me, there is nothing more satisfying than going home after solving a problem at work. This makes me feel that I am not too bad :-). It also gives me the desire to go back to work tomorrow.&lt;/p&gt;

&lt;p&gt;There are many answers to this question, as everyone has his proper priority in Life. Somme can say:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's seeing their child&lt;/li&gt;
&lt;li&gt;it's the feeling to be back home&lt;/li&gt;
&lt;li&gt;It's the fact that they can take rest &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So what is yours ?&lt;/p&gt;

</description>
      <category>devlife</category>
    </item>
    <item>
      <title>Why I decide to use vim in 2021</title>
      <dc:creator>AinaJ</dc:creator>
      <pubDate>Mon, 11 Oct 2021 17:37:51 +0000</pubDate>
      <link>https://dev.to/aina_j/why-i-decide-to-use-vim-in-2021-3j4e</link>
      <guid>https://dev.to/aina_j/why-i-decide-to-use-vim-in-2021-3j4e</guid>
      <description>&lt;h1&gt;
  
  
  Why I decide to use vim in 2021
&lt;/h1&gt;

&lt;p&gt;When I first learn programming my teacher use &lt;strong&gt;vi&lt;/strong&gt; to teach us.&lt;br&gt;
That was a horrible experience for me. I see it so difficult and even not obvious:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;why do I need to hit &lt;strong&gt;i&lt;/strong&gt; before I can insert text?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I know there is many text editors that makes life easy. So why should I use vi or vim.&lt;/p&gt;

&lt;h2&gt;
  
  
  Modern IDE takes a lot of memories
&lt;/h2&gt;

&lt;p&gt;I used so many IDE like Eclipse, Boa and VS Code. VS Code is great and so powerful. These last two years I use it in my daily life as programmer. &lt;br&gt;
But times come when I need to debug multiple microservices. I need to run at least 4 microservices and a desktop application. In addition to that docker desktop should run some service like database, rabbitMQ, redis. Then my PC start to slow down and time to time it blocked because memory is almost full.&lt;/p&gt;

&lt;p&gt;Looking at the task manager I start to kill every process that I don't really need. But not too much progress. Then I notice that VS Code takes really many memories when debugging. I switch to eclipse, but it takes even more memory.&lt;br&gt;
I was so frustrated because I can not get my work done.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I decide to try vim
&lt;/h2&gt;

&lt;p&gt;Questions start to fill my mind: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;why modern IDE take so many memories on my computer?&lt;/p&gt;

&lt;p&gt;Do I really need to take so much memory to write code?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Peoples in a decade before doesn't even have half of my memory to get their work done.&lt;br&gt;
But they manage to write great software. Some even build OS that we still use nowadays.&lt;/p&gt;

&lt;p&gt;Then I remember my teacher using vi for programming.&lt;br&gt;
Is &lt;strong&gt;vi&lt;/strong&gt; really lightweight? Can it be used as an IDE?&lt;/p&gt;

&lt;p&gt;I start to experiment vim as it is an improved version of vi. And many used it as an IDE.&lt;/p&gt;

&lt;p&gt;Vim installed on my PC and with a great surprise it only takes less than 50Mb when debugging. It was configured with plugin like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;vimspector for debugging&lt;/li&gt;
&lt;li&gt;Nerdtree for file browsing&lt;/li&gt;
&lt;li&gt;FZF coupled with Ag/Rg for search&lt;/li&gt;
&lt;li&gt;vim-fugitive for git.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So I decide to learn and use vim each day I put my hand on computer.&lt;br&gt;
I manged to get my work done as my PC doesn't block anymore.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Modern IDE are great and can make your daily job easy. But vim is still a tool that programmers should consider.&lt;br&gt;
If you are like me who need to debug multiple program at the same time or need to debug on a server environment vim is probably the tool you need.&lt;br&gt;
Although it takes time to master, believe me it can bring you a comfort you never saw before.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The CPython interpreter GIL</title>
      <dc:creator>AinaJ</dc:creator>
      <pubDate>Tue, 17 Aug 2021 08:46:02 +0000</pubDate>
      <link>https://dev.to/aina_j/the-cpython-interpreter-gil-240d</link>
      <guid>https://dev.to/aina_j/the-cpython-interpreter-gil-240d</guid>
      <description>&lt;h1&gt;
  
  
  The CPython interpreter GIL
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Python is one of the most popular programming language in the last decade.&lt;br&gt;
Although the syntax is easy to read there are some lack to consider with python.&lt;br&gt;
Many consider python too slow when doing multi-threading. This is principally due to the original implementation of python Cpython wich use one thing called GIL.&lt;br&gt;
In this article I'll try to explain you what is GIL, how it work, and why it is so important for python.&lt;/p&gt;
&lt;h2&gt;
  
  
  Cpython memory management
&lt;/h2&gt;

&lt;p&gt;To start let's understand how python memory management is done in the official implementation of python Cpython. For every object in python there are three things stored: its value, its type, and the reference-counter.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkcvmxg4lwom0yr1qdkla.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkcvmxg4lwom0yr1qdkla.png" alt="Alt Text" width="388" height="191"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The reference counter is what Cpython use to decide if object must be removed from memory or not. When some add reference to the object its reference counter increment and decrement when some remove reference to it. It will be removed from memory when the reference counter is zero. That's mean there is no more things making reference to the object.&lt;br&gt;
The reference count field can be examined using the sys.getrefcount function (notice that the value returned by this function is always 1 more as the function also has a reference to the object when called)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;toto&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getrefcount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="mi"&gt;3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The reference count of A is 3 because in addition to the two line before sys.getrefcount also make a reference to A. It will directly drop to 2 after we run this function.&lt;br&gt;
Let's add reference to A with a variable C and see what happen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getrefcount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="mi"&gt;4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the reference increases by 1 and become 4.&lt;/p&gt;

&lt;p&gt;With del() function we can delete object from memory so we can remove reference.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;del&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getrefcount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="mi"&gt;3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bingo! The reference decreases by 1 because we delete on reference.&lt;/p&gt;

&lt;p&gt;That's pretty good. But how if multiple part of program make change in the reference counter at the same time. With the concept of multi-thread this can happen. Imagine both thread1 and thread2 use the variable A. Thread1 decrease the value of A reference counter at the same time as thread2 increase it. This can result that reference counter of A never rich zero or reach zero to soon while other thread still have reference to it. This is one of the reason python use GIL. So what is really GIL.&lt;/p&gt;

&lt;p&gt;## What is GIL?&lt;br&gt;
The GIL or the Global Interpreter Lock is a mutex or a lock used in language like python and nodejs to allow only one thread running at a time. It's ensure safe memory management and make single thread program more faster. It was first introduced by Guido Van Rossum in August 1992.&lt;/p&gt;

&lt;p&gt;So what the GIL do for Cpython&lt;br&gt;
Back with the problem of multi-thread and reference counter GIL bring a great solution. Only one thread run at any time so we are pretty sure that one thread only can make a change in the reference counter during execution. That's is one of the main reason GIL is used with python. But there is also the fact that Cpython use so many C extensions and library. These extensions can interact directly with memory and can cause memory problem. GIL can prevent this with the lock system it implement so we can run these extension in a safe way. It also provide a performance boost for single-threaded programs. &lt;br&gt;
That's about the positive side. But what about the other face of GIL.&lt;/p&gt;

&lt;p&gt;GIL as we saw above allow only one thread to run at any time. Let's take a look at it in practice.&lt;br&gt;
We are going to compare two program that do the same thing: count back from a given number.&lt;br&gt;
The first one is single-threaded:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt; 


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;count_back&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="n"&gt;START&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;50000000&lt;/span&gt;

&lt;span class="n"&gt;t1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nf"&gt;count_back&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;START&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;total execution time is: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;t1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;total execution time is:  3.8295717239379883&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As we can see it takes 3,83 seconds to do the count back.&lt;/p&gt;

&lt;p&gt;Now let's do that with multi-threaded program.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;threading&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Thread&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;count_back&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="n"&gt;START&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;50000000&lt;/span&gt;

&lt;span class="c1"&gt;# creation of threads
&lt;/span&gt;&lt;span class="n"&gt;thread1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Thread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;count_back&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;START&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,))&lt;/span&gt;
&lt;span class="n"&gt;thread2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Thread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;count_back&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;START&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,))&lt;/span&gt;

&lt;span class="c1"&gt;# execution
&lt;/span&gt;&lt;span class="n"&gt;t1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;thread1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;thread2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;thread1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;thread2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;total execution time is: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;t1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;total execution time is:  4.143504619598389&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I run it with 2 core CPU.&lt;br&gt;
It supposed to be faster than the single-threaded one but it's not the case. It take even more time.&lt;br&gt;
Python execute each thread one by one so even with a multi-core processor multi-threaded program is executed like single-threaded.&lt;br&gt;
That's is one of the reason python is so slow especially with multi-threaded program. Let's understand how GIL work with multi-threaded.&lt;/p&gt;

&lt;h2&gt;
  
  
  How GIL work?
&lt;/h2&gt;

&lt;p&gt;When a thread start it need to acquire the GIL first. Also when it finishes or have to do some IO operation it release the GIL so the next thread can acquire the GIL and be executed.&lt;br&gt;
It's like running 400m relay. Let's assume every runner is a thread and the stick is the GIL. When someone want to make a run he need to get the stick before. That's is how GIL work. It's simple stupid but it works great especially with single-threaded program. Performance boost can be really important. From python2 to python3 there was some notable improvement made inside the GIL by Antoine Pitrou. And it makes python3 GIL more reliable.&lt;/p&gt;

&lt;p&gt;You can visualize it in this image below.&lt;br&gt;
Example of 2 thread running concurrently&lt;/p&gt;

&lt;h2&gt;
  
  
  Alternative to GIL
&lt;/h2&gt;

&lt;p&gt;GIL can make your program slower with the original implementation of python Cpython.&lt;br&gt;
Some implementation doesn't use GIL, like Jython, pypy. As Guido says if you want your python program to run faster use pypy.&lt;br&gt;
Here is an output of the program above with pypy.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;total execution time is:  0.13152098655700684&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There is also multi-processing in python to deal with performance in Cpython. It will run one interpreter for each process so one GIL per each.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We saw that GIL is an important part of python. Even if it makes your program run slower it offers more advantage for python. It's one of the reason that makes python so popular today with the  easy support of C extensions.&lt;br&gt;
As a programmer you can not really see the impact of GIL but it always good to know what is behind the wheel. That's was this article for. &lt;br&gt;
Hope you enjoy.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
