Python Performance Profiling: The Guts And The Glory

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


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.


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.


performance, profiling, python

Speaking experience

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

* MongoDB World 2015:
* Open Source Bridge 2015:
* PyCon 2015:
* MongoDB World 2014:
* PyCon Montreal 2014:
* PyCon APAC 2014:


Leave a private comment to organizers about this proposal