The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K followers.

Member-only story

Writing Performant Parallel Python Code

Distinguish IO-bound and CPU-bound applications in Python to write code that runs faster

Thiago Candido
The Startup
Published in
4 min readNov 1, 2020

--

Image from MonikaP by Pixabay

In what cases is the use of libraries for concurrent application development appropriate and can result in increased performance using Python?

Python Interpreter

To answer this question, we first need to discuss how the Python interpreter works. In the course of the story, when detailing how the interpreter works, we will be referring to CPython, which brings the reference implementation of the Python language and is also the standard and most used interpreter among developers.

CPython is the reference interpreter, created by Guido van Rossum, creator of the Python language. With the popularization of the language, other interpreters were created by the community, such as IronPython (.NET), Jython (JVM), PyPy, Stackless, etc.

When executing the code, the interpreter uses a security mechanism called GIL, or Global Interpreter Lock. This lock structure was originally implemented to eliminate problems related to memory management in competing application scenarios. To execute the interpreter's instructions, it is necessary to obtain control of the GIL by the thread.

Locks are one synchronization

--

--

The Startup
The Startup

Published in The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K followers.

Thiago Candido
Thiago Candido

Written by Thiago Candido

I help people to use their products and services data intelligently @eximiaco

No responses yet