Timing your code is a useful capability to have.
In this video we use timeit to measure the amount of time two functions take to execute.
The two functions are two ways of building up a list in Python: a for loop and a list comprehension. We can compare the execution time to see what is faster. Spoiler alert: the list comprehension function was faster!
Give it a go in your own code!
On this page of the site you can watch the video online How To Use Python Timeit (Simple Example) with a duration of hours minute second in good quality, which was uploaded by the user Make That Work 16 September 2022, share the link with friends and acquaintances, this video has already been watched 100 times on youtube and it was liked by 3 viewers. Enjoy your viewing!