PyBites Python Tip / Get 4 weekly tips

Timeit decorator

Here we use a decorator to time the duration of a function execution:

Copy the code

Subscribe to our Python tips to copy the code

Spread the word

Check out more resources

Login to get more resources

Get all our Python tips

Get our full collection of 250 (and growing) Python tips, each with more details / explanations.

Buy the book

"The discussions are succinct yet thorough enough to give you a solid grasp of the particular problem. I just wish I would have had this book when I started learning Python." - Daniel H

"Bob and Julian are the masters at aggregating these small snippets of code that can really make certain aspects of coding easier." - Jesse B

"This is now my favourite first Python go-to reference." - Anthony L

"Do you ever go on one of those cooking websites for a recipe and have to scroll for what feels like an eternity to get to the ingredients and the 4 steps the recipe actually takes? This is the opposite of that." - Sergio S