Are your #python programs running slow? Here’s how you can make them 7x faster.
▻https://hackernoon.com/are-your-python-programs-running-slow-heres-how-you-can-make-them-7x-fas
We all know that Python is much slower than statically-typed #programming languages like C, C++, Java and some dynamic languages too like JavaScript and PHP. Let’s look at the reasons why Python is much slower compared to these languages and what can we do to increase its execution speed.Why is Python slow?The default implementation of Python ‘CPython’ uses GIL (Global Interpreter Lock) to execute exactly one thread at the same time, even if run on a multi-core processor as GIL works only on one core regardless of the number of cores present in the machine. Each core in the CPU has its own GIL, so a quad-core CPU will have 4 GILs running separately with its own interpreter. To make our python programs run parallel we use multithreading and multiprocessing.Multithreading does not make much (...)