Benchmarking, Profiling, and Optimizing Your Python Code Easily Identify Bottlenecks and Efficiently Speed Up Your Python Code

  • Coen de Groot

Your browser needs to be JavaScript capable to view this video

Try reloading this page, or reviewing your browser settings

You're watching a preview of subscription content. Log in to check access

Some programmers don’t use Python because they think it is too slow. Yet writing fast-enough programs in Python often takes less time than in other languages. In this video, you will learn how to effectively and efficiently speed up your Python programs.

We start by looking at how to measure the speed of a program, so you can see the impact of your changes. And we will discover where your program spends most of its time to help you focus your efforts. You will see how to create performance graphs and drill down into the detail. Next, we move on to optimizing the code by changing the flow and structure. Some approaches take more processing power than others, and we will look at how to use code complexity to express this and help you choose the best algorithm. We will see some examples of switching to a different algorithm and the impact on the code’s speed. You will see some simple techniques to cache the results from your functions. Moving code out of large loops can also have a significant impact. Having restructured the code, you will learn how to speed up individual lines of code. We will look at ten common tasks in Python and compare the different ways to achieve them.

After watching this video, you will be able to measure code performance to see what works, profile your code to discover where to focus, change the code structure and flow to improve speed, and go through your code line by line to use faster Python syntax.

What You Will Learn

  • Benchmark Python code and track the progress of optimization efforts

  • Profile Python code and discover low-hanging fruit to focus your optimization

  • Change the code flow and structure to minimize how much code gets run

  • Choose the fastest Python syntax, line by line, to speed everything up

Who This Video Is For

Intermediate to experienced Python programmers who want to speed up existing Python code and write faster new Python code.

In this video, you will learn how to effectively and efficiently speed up your Python programs by benchmarking, profiling, and optimizing your python code.

About The Author

Coen de Groot

Coen de Groot is a freelance Python developer and trainer. He has been passionate about computers and programming since the late ‘70s when he built his first ‘computer’.

After studying computer science at Leiden University in the Netherlands, Coen worked as a software engineer for several companies, from a large oil company to small start-ups, working in software support, delivering training, and leading software teams.

For the past ten years Coen has been programming predominantly in Python, with hints of SQL, JavaScript, and others. He still enjoys learning more Python and passing on that knowledge to others face to face, in writing, or on video.

 

About this video

Author(s)
Coen de Groot
DOI
https://doi.org/10.1007/978-1-4842-6776-9
Online ISBN
978-1-4842-6776-9
Total duration
1 hr 32 min
Publisher
Apress
Copyright information
© Coen De Groot 2020

Related content

Video Transcript

Welcome to Benchmarking, Profiling, and Optimising your Python code. We will look at the most effective optimization workflow, how to focus your efforts by measuring your code, how to speed up your program by restructuring your code, and discover the fastest individual Python statements for line by line improvements.

My name is Coen de Groot. I am a freelance Python developer and trainer with many years experience. I help my clients make better use of their data, give their customers a better experience, write better Python code, and more.