This guide aims to summarize popular methods for boosting the execution speed of your Python code.

Python is an amazing programming language, but it has two huge downsides when compared to compiled languages.

  1. The first one is GIL or Global Interpreter Lock. GIL is an actual process lock that forces a Python interpreter to work on a single process and use only one of the cores in your CPU. Due to this lock, Python is both simple and stable but also is very slow compared to other programming languages like C or Java.
  2. The second downside is rather universal for non-statically typed aka dynamically typed programming languages. Simply put, when you do not specify the data type of the variable that you are going to use and rely on dynamic type assignment, you end up with much slower execution performance.

Luckily there are several ways to speed up your Python code.

  • Bypass GIL (Concurrency/GIL persist)
  • No GIL (True parallelism) + Optional Static Typing
  • No GIL (True parallelism) + Mandatory Static Typing

#programming #python

A Guide to Improving Your Python Performance Speed
2.05 GEEK