Functional Programming in Python
summary
Claims that Python supports functional style enough to be useful, demonstrates partial function application, currying, closures, decorators and function composition, and shows concrete code: a CSV parser reimplemented as composed map/filter/partial steps and a K‑means pipeline that runs on PySpark. Uses tool libraries (funktools, fn.py, toolz) for currying and composition, notes missing niceties like nicer lambda syntax and builtin immutability, and the examples run and clarify tradeoffs.
AI-written summary · about
chapters (38)
- 0:00Welcome Remarks
- 0:19About Me (Daniel Kirsch)
- 1:06About This Talk
- 1:20Disclaimer - PEP 20
- 3:19Vocabulary of Concepts
- 3:47Purity (Functions Without Side-Effects)
- 4:23First Class Functions
- 4:54Higher-Order Functions
- 5:32Decorators as Higher-Order Functions
- 5:49Partial Function Application
- 7:15Currying
- 9:05Interlude: Closures
- 9:55Currying Example from the Standard Library
- 10:53Functional Collection Transformations (Map, Filter, & Reduce)
- 11:04Map
- 11:39Filter
- 12:12Reduce
- 14:01Function Composition
- 15:16Example: A Bad CSV Parser (1/3)
- 15:38Example: Imperative Python (2/3)
- 16:18Example: Functional Python (3/3)
- 20:35Example: PySpark
- 21:26Example: K-Means
- 23:15Main Takeaways
- 23:53What is Missing in Python
- 25:00Functional Libraries
- 25:38Nicer Lambda Syntax
- 26:05Other Interesting Stuff
- 26:16Other Talks (Where I Have Stolen Material)
- 27:13More FP?
- 27:38Thank You
- 28:10Audience Questions: Do you have a workaround for Immutability?
- 29:58Audience Questions: Composition in Python is ugly, any workaround?
- 31:43Audience Comment: Cannot assume the Pure Function example won't have a side-effect.
- 32:43Audience Question: Underscore construct in PySpark
- 34:39Audience Question: Any Python packages that try to mimic Scala like functional programming?
- 35:34Audience Question: List Comprehensions are faster than map(), what is your take?
- 38:17Last Question: Have you looked at Hy dialect?
related talks
30mFunctional Programming in Python
27mFunctional Programming for Pythonistas
02h 43mFunctional Python
37mFunctional Programming for Data Scientists
43mFunctional Programming in an Imperative World. Maybe
29mWriting Functional Code in Python
28mSimplifying Python Code through the Lens of Functional Programming
33mPythonic `functional` (`iter`)tools for your data challenges
