Daniel Kirsch - Functional Programming in Python

Опубликовано: 31 Май 2016
на канале: PyData
26,994
418

PyData Berlin 2016

There should be one-- and preferably only one --obvious way to do it. And that is functional - at least in my opinion. I'm working with Python for a living since two years after coming from a background in Ruby, Haskell, Clojure, and some more languages. Since then I have tried to marry ideomatic Python to the functional style I learned to love. It's time to share my experience.

I will talk about

higher order functions
partial function application and currying
function composition
functional collection transformations (and why they are relevant for PySpark)
(fake) lazy evaluation

and how it all relates to Python (and what's missing).

Slides: https://github.com/kirel/functional-p...

00:00 Welcome Remarks
00:19 About Me (Daniel Kirsch)
01:06 About This Talk
01:20 Disclaimer - PEP 20
03:19 Vocabulary of Concepts
03:47 Purity (Functions Without Side-Effects)
04:23 First Class Functions
04:54 Higher-Order Functions
05:32 Decorators as Higher-Order Functions
05:49 Partial Function Application
07:15 Currying
09:05 Interlude: Closures
09:55 Currying Example from the Standard Library
10:53 Functional Collection Transformations (Map, Filter, & Reduce)
11:04 Map
11:39 Filter
12:12 Reduce
14:01 Function Composition
15:16 Example: A Bad CSV Parser (1/3)
15:38 Example: Imperative Python (2/3)
16:18 Example: Functional Python (3/3)
20:35 Example: PySpark
21:26 Example: K-Means
23:15 Main Takeaways
23:53 What is Missing in Python
25:00 Functional Libraries
25:38 Nicer Lambda Syntax
26:05 Other Interesting Stuff
26:16 Other Talks (Where I Have Stolen Material)
27:13 More FP?
27:38 Thank You
28:10 Audience Questions: Do you have a workaround for Immutability?
29:58 Audience Questions: Composition in Python is ugly, any workaround?
31:43 Audience Comment: Cannot assume the Pure Function example won't have a side-effect.
32:43 Audience Question: Underscore construct in PySpark
34:39 Audience Question: Any Python packages that try to mimic Scala like functional programming?
35:34 Audience Question: List Comprehensions are faster than map(), what is your take?
38:17 Last Question: Have you looked at Hy dialect?

S/o to https://github.com/hfzvc for the video timestamps!

Want to help add timestamps to our YouTube videos to help with discoverability? Find out more here: https://github.com/numfocus/YouTubeVi...


Смотрите видео Daniel Kirsch - Functional Programming in Python онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал PyData 31 Май 2016. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 26,994 раз и оно понравилось 418 посетителям.