Stop Using map() and filter() Like This in Python

ArjanCodes May 30, 2025
Video Thumbnail

About

No channel description available.

Video Description

💡 Learn how to design great software in 7 steps: https://arjan.codes/designguide. Think map() and filter() are always better than for loops? Not so fast. In this video, I’ll walk you through four situations where functional code actually makes things worse—and explain why the classic for loop still deserves a place in your toolbox. 🔥 GitHub Repository: https://git.arjan.codes/2025/map 🎓 ArjanCodes Courses: https://www.arjancodes.com/courses. 💬 Join my Discord server: https://discord.arjan.codes. ⌨️ Keyboard I’m using: https://amzn.to/49YM97v. 🔖 Chapters: 0:00 Intro 0:26 The Classic For Loop 1:15 Using filter() and map() 2:33 List Comprehensions 3:22 Performance Comparison 4:32 When Not to Use map() or filter() 4:51 Case 1: Complex Logic 7:54 Case 2: Exception Handling 10:33 Case 3: Side Effects (e.g., Writing to File or Logging) 12:36 Case 4: Early Exit with break or continue 13:56 TL;DR 15:44 Final Thoughts #arjancodes #softwaredesign #python