Python Decorators in 1 Minute!

↔️ ↕️


what are decorators in Python let's say

I'm building a python project and I

really want to time how long each of

these functions takes to run sure I

could go through each of these functions

and Implement some timing functionality

for each of them but what if I have

hundreds of functions that would take

forever instead I'm going to create a

function to do it for me let's call it

tick tock and it's going to take in a

function as an input now inside let's

create a function called wrapper now in

a wrapper let's define a start time and

then let's run the function that we

passed into Tick Tock and then after the

function is executed let's determine how

long it took by taking the current time

minus our start time now let's print

that it took T2 seconds to execute and

now down here let's return this wrapper

Related queries:

how to design python program
how to design python gui
how to design python project
how to design python classes
how to design python api
how to mock decorator python
how to write decorator python
how to create decorator python
how to test decorator python