Decorators demystified
summary
Explains what happens when you use Python's @ decorator syntax by diving into scopes, namespaces and closures to show how decorators work internally. Uses these language features to walk through building a custom decorator by hand, aimed at developers with intermediate Python knowledge.
AI-written summary · about
chapters (21)
- 0:00Start
- 1:41A simple software cache
- 2:33Use functools.lru_cache, not this!!!
- 3:09Factorial and fibonacci functions
- 3:49How are we accessing this attribute?
- 4:38How are recursive calls possible?
- 4:55A simpler case
- 6:21Python namespaces examples
- 8:58Python namespaces lifetimes
- 12:17Python nested scopes
- 15:21Python scopes
- 16:39Another more complex case
- 18:48There is a closure!
- 24:16DRY: Don't Repeat Yourself!
- 24:43Original function is not modified
- 26:18Create original fibonacci function
- 26:37Create alternative name pointing to the same function object
- 26:52Replace original name with new a function which calls the alternative name
- 28:13A factory of memoization functions
- 30:23Decorators demystified
- 30:56Q&A
related talks
01mDecorators Demystified
02h 21mIntroduction to Decorators: Power Up Your Python Code
29mOn the Use and Misuse of Decorators
29mHow Decorators Function
02h 15mAll about decorators
01mTutorial Sneak Peak: "All about decorators"
03mLightning Talk: Python Decorators
02h 32mIntroduction to Decorators: Power UP Your Python Code
