Python Performance Profiling: The Guts And The Glory

*
Proposal
Short Form
Beginner
Scheduled: Tuesday, June 21, 2016 from 4:45 – 5:30pm

Excerpt

Your Python program is too slow, and you need to optimize it. Where do you start? With the right tools, you can optimize your code where it counts. With the Python profiler “Yappi” we’ll learn how to find the maximum performance wins with minimum effort.

Description

My boss alerted me to an article on a popular site, which claimed to show that my open-source Python client for MongoDB is three times slower than the Javascript client. Anxiety immediately set in: Was this true? Could I improve it? What should I tell my boss?

I’ll describe three open-source profilers for Python, and explain why Yappi is the right profiler for this job.

Optimization is like debugging: we use the scientific method. We form a hypothesis about what changes we can make to our code to make it faster, and we estimate how much improvement an optimization can yield. Then comes the second part of the scientific method: we test the hypothesis with an experiment.

And now, let’s return to the problem at hand: Is my code slow? We’ll use Yappi to form some hypotheses, then validate them with tests. Finally, I have an answer to my boss’s question, and better yet, I can back up my answer with hard evidence.

Tags

performance, profiling, python

Speaking experience

I have given this talk at PyCon. Here are some videos of me speaking:

* MongoDB World 2015: https://www.mongodb.com/presentations/mongodb-drivers-and-high-availability-deep-dive
* Open Source Bridge 2015: https://www.youtube.com/watch?v=GSk0tIjDT10
* PyCon 2015: http://emptysqua.re/blog/pycon-video-eventually-correct-async-testing/
* MongoDB World 2014: http://www.mongodb.com/presentations/weather-century-part-3-visualization
* PyCon Montreal 2014: http://emptysqua.re/blog/pycon-2014-video-what-is-async/
* PyCon APAC 2014: https://www.youtube.com/watch?v=BOKcZjI5zME

Speaker

Leave a private comment to organizers about this proposal