Python Multithreading Misconception
One of the misconceptions that developers say that python is too slow and python multithreading sucks. Well, it’s not true. let’s broaden this topic. A lot of pythonists used to say GIL (Global Interpreter Lock) is the cause of the performance of python. They say it prevents you from running more than one thread at a time. You can’t get the real concurrency feature in python. Yes, it’s true but the truth is multithreading is still perfect. Yeah, there are some exceptions which you have to lookout. And depending on the cases, it might need GIL otherwise why to make ur development life harder and being burn out. What Gil restricts that two bytecode can’t run parallelly. Threading can allow concurrency and reduces time consumption, increase performance.
As I mention here about GIL a lot but what actually it is? Well, Gil is a feature of CPython which default python manages memory. but Jython and IronPython lack the GIL coz it’s an implementation detail of the underlying VM. I tired about it and here is the result.
lol, they don’t have. They handle dynamic memory differently and can safely run the python code in multiple threads at the same time. And I think Cpython can’t remove the GIL feature too. And what’s the solution in order to achieve Multithreading. Well, Many python libraries bypass multithreading issue by using C/C++ extensions.I recommend multiprocessing to get the benefits of all the cores. One more thing GIL is only a problem in a multiprocessor environment.
Conclusion
We can’t conclude that Multithreading can’t be achieved, you can still perform multithreading in Jython, IronPython even your default(Cpython) one too. And GIL is a relevant topic, we will discuss more it and memory management behind the Python interpreter.