Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Python High Performance

You're reading from   Mastering Python High Performance Learn how to optimize your code and Python performance with this vital guide to Python performance profiling and benchmarking

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher
ISBN-13 9781783989300
Length 260 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Fernando Donglio Fernando Donglio
Author Profile Icon Fernando Donglio
Fernando Donglio
Arrow right icon
View More author details
Toc

Getting to know our new best friends: the profilers

After all the theory and generic examples from the previous chapter, it is time for some real Python. So, let's begin with two of the most known and used Python profilers: cProfile and line_profiler. They will help us profile our code in two different ways.

On one hand, we have cProfile (https://docs.python.org/2/library/profile.html#module-cProfile), It comes by default with Python since version 2.5 and is the recommended profiler for most use cases. At least that is what the official Python documentation says about it. On the other hand, we have line_profiler (https://github.com/rkern/line_profiler), which is not an official part of the Python programming language, but it's a well-known profiler out there.

Let's go over both of them in more detail.

cProfile

Like I've already mentioned, cProfile comes by default with the standard Python interpreter (cPython) since version 2.5. Other versions, such as PyPy, don't...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image