Not planned
Description
I'm learning about Python decorators and would appreciate feedback on my implementation.
Here's my example code:
@timer
def slow_function():
import time
time.sleep(2)
return "Done"
Specifically, I'd like to know:
- Is this a correct usage of decorators?
- What's missing from the implementation (I notice the
@timer
decorator itself isn't defined) - Best practices for implementing timing decorators
Thank you for your help!
Metadata
Metadata
Assignees
Labels
No labels
Activity
hugovk commentedon May 22, 2025
This is the issue tracker for the Python language itself.
Please open a topic in the help forum to ask about your own code:
https://discuss.python.org/c/help/7