The Python Papers

The Python Papers

Timing Your Python Code with Built-in Libraries

Mike Driscoll's avatar
Mike Driscoll
Aug 17, 2026
∙ Paid

Sometimes you want to know why your code is slow. The process of determining the slowness is called profiling. In this article, you will look at using some of Python’s internal libraries to help you track down your slow code.

Using timeit

Python comes with a module called timeit. You can use it to time small code snippets. The timeit module uses platform-…

User's avatar

Continue reading this post for free, courtesy of Mike Driscoll.

Or purchase a paid subscription.
© 2026 Mike Driscoll · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture