Episode 124: Exploring Recursion in Python With Al Sweigart
Sep 09, 2022 1h 20m
Have you wanted to understand recursion and how to use it in Python? Are you familiar with the call stack and how it relates to tracebacks? This week on the show, Al Sweigart talks about his new book, “The Recursive Book of Recursion.”
Recursion is one of those concepts held as a tenet of high-level computer science priesthood. Al explains the fundamentals of writing recursive functions and a critical missing piece in understanding how they operate, the call stack. After completing his research, he concluded that it’s a technique that you should understand but rarely use.
He also shares the few cases where recursion is an appropriate solution. Along the way, we talk about directed acyclic graphs, solving mazes, exploring file trees, and creating fractal images.
Course Spotlight: Caching in Python With lru_cache
Caching is an essential optimization technique. In this video course, you’ll learn how to use Python’s @lru_cache decorator to cache the results of your functions using the LRU cache strategy. This is a powerful technique you can use to leverage the power of caching in your implementations.
- 00:00:00 – Introduction
- 00:01:55 – The Recursive Book of Recursion
- 00:02:55 – A Beginner’s Guide to Recursion - YouTube
- 00:05:41 – What is recursion?
- 00:10:17 – Understanding the call stack
- 00:12:15 – Languages moving from GOTO statements to functions and a stack
- 00:21:11 – A common recursion example of factorials
- 00:26:00 – Fibonacci sequence and memoization
- 00:30:25 – Cautionary advice on applying recursion
- 00:32:55 – What is recursion useful for?
- 00:39:56 – Video Course Spotlight
- 00:41:14 – Recursion and directed acyclic graphs
- 00:45:46 – Book examples
- 00:49:50 – Thoughts on tail recursion
- 00:54:34 – How has the scope of the book evolved?
- 01:00:34 – Creating examples in two languages
- 01:02:37 – Upcoming projects
- 01:05:19 – Examples of the projects in the book
- 01:10:30 – What are you excited about in the world of Python?
- 01:14:50 – What do you want to learn next?
- 01:19:06 – How can people follow your work?
- 01:19:48 – Thanks and goodbye
- The Recursive Book of Recursion | No Starch Press
- Recursion for Beginners: A Beginner’s Guide to Recursion - YouTube
- The Invent with Python Blog
- Recursion in Python
- factorial | Definition, Symbol, & Facts | Britannica
- Fibonacci sequence | Definition, Formula, Numbers, Ratio, & Facts | Britannica
- A Python Guide to the Fibonacci Sequence – Real Python
- Directed acyclic graph - Wikipedia
- Dynamic programming - Wikipedia
- The Little Schemer : Friedman, Daniel P : Internet Archive
- Book Review: The Little Schemer - The Invent with Python Blog
- Droste effect - Wikipedia
- Episode #33: Going Beyond the Basic Stuff With Python and Al Sweigart – The Real Python Podcast
- Episode #80: Make Your Python App Interactive With a Text User Interface (TUI) – The Real Python Podcast
- BeeWare — Write once. Deploy everywhere.
- Episode #22: Create Cross-Platform Python GUI Apps With BeeWare – The Real Python Podcast
- Origami with Jo Nakashima - YouTube
- Invent with Python