~/talk

Introduction to Decorators: Power Up Your Python Code

Talkat PyCon US 2020 · 2020-04-15..04-23· [python]
links:none on file
slides:none on file

Step-by-step tutorial that actually shows working code, exercises, and a repo: implements timer trace register count_calls and a use_unit decorator with live fixes (args/*kwargs, return values, functools.wraps). Demonstrations use time.perf_counter, func_tools.wraps and the pint unit library and mention Flask/click/Numba patterns: uses time.perf_counter and functools.wraps and pint. Includes a striking demo where naive fib(32) causes ~7 million calls: fib(32) triggers ~7 million calls*. Code on GitHub runs as shown.

AI-written summary · about

  1. 0:00Start
  2. 1:44What Are Decorators
  3. 3:26What this Course Will Include
  4. 4:18Introduction to Decorators
  5. 5:46Inner Functions
  6. 7:32Functions Are First Class Objects
  7. 11:43Reversed Print Function
  8. 21:57Inside Function
  9. 30:07Decorator Syntax
  10. 35:05Wrapper Decorator
  11. 44:19Decorator Factory
  12. 59:14Trace Decorator
  13. 1:00:59Random Greet
  14. 1:05:37Wrapper Function
  15. 1:07:33Test Cases
  16. 1:13:47Timer Decorator
  17. 1:21:08Register Decorator
  18. 1:23:01Rubber Language Parser
  19. 1:30:21Summary
  20. 1:32:54Using Classes as Decorators
  21. 1:34:34Count Calls
  22. 1:35:09Fibonacci Numbers
  23. 1:36:03Recursive Function
  24. 1:48:10Recap
  25. 1:49:08A Decorator Is a Function
  26. 1:50:42Adder Class
  27. 1:51:46Make a Class Callable
  28. 2:00:59Decorators in Classes
  29. 2:11:26Fifth Task
  30. 2:11:47Create Decorators That Can Take Arguments
  31. 2:16:25Unit Registry
  32. 2:18:44Cubase Units
  33. 2:24:29Create a Decorator
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.