Advanced Python: Functional Programming
Published by Pearson
Use functional programming to improve the quality of your code
- Demonstrates how to design libraries or applications while improving the readability, testability, or understandability of code
- Intended for Python users who write large systems or frameworks and want to better structure their code
- Introduces functional programming approaches in Python, including comprehension syntax and generator expressions
- Tackles methods to improve the readability and testability of code, using “first-class” functions, immutability, and property tests
Boost your Python code’s performance, readability, and testability with functional programming approaches. You’ll learn important functions such as map, filter, functools.reduce, and itertools.accumulate and tackle common patterns that can be addressed using functional approaches. We’ll cover immutability and how it makes our code more testable, memoization and caching, and lazy evaluation, and close with writing robust tests using pytest and hypothesis to assert our code’s correctness. This approach is especially valuable for data scientists looking to build scalable and maintainable data solutions.
What you’ll learn and how you can apply it
- Apply the basic functional programming functions map, filter, functools.reduce, and itertools.accumulate
- Simplify code and improve testing strategies using first-class functions, closures, and functional patterns
- Create more predictable and testable code by applying immutability, purity, and referential transparency
- Use pytest and hypothesis to write property-based tests
This live event is for you because...
- You are an Intermediate Python user
- You write larger systems or frameworks and want to understand better ways to structure code
- You want to design libraries or applications and improve the readability, testability, or understandability of your code
- You are a data scientist who wants to improve the quality of your code
- You are a data scientist who wants to understand how to make the best use of APIs like pandas
Prerequisites
- Python experience (≥5k lines of code).
- Broad familiarity with Python syntax.
- [Optional] Some familiarity with functional approaches (e.g., map, filter).
Recommended Preparation
- Read: Python Distilled by David M. Beazley
Recommended Follow-up
- Read: Effective Python, 3rd Edition, by Brett Slatkin
- Attend: Advanced Python series of live courses by James Powell and Cameron Riddell
Schedule
The time frames are only estimates and may vary according to how the class is progressing.
Segment 1: Functional Programming Basics (50 mins)
- What are basic functional programming approaches in Python?
- What is comprehension syntax? What are generator expressions?
- What are
map
,filter
,functools.reduce
, anditertools.accumulate
? - Q&A
Break (10 mins)
Segment 2: First-Class Functions and Closures (50 mins)
- What are “first-class” functions?
- What are closures?
- How might I simplify my code and testing by designing in terms of functions?
- What common patterns arise that can be addressed by functional approaches?
- Q&A
Break (10 mins)
Segment 3: Immutability and Code Quality (50 mins)
- What is immutability?
- How does it aid in making our code more testable and more understandable?
- How can I employ simple techniques to operate with immutable data, and how can I maximize performance of my code?
- Q&A
Break (10 mins)
Segment 4: Reliability and Resource-Efficiency (50 mins)
- What is purity and referential transparency?
- How do these relate to memorization and caching?
- What is lazy evaluation?
- What is the difference between concrete and abstract representations of data?
- What is a generator in Python, and under what circumstances are they the best way to model a computation?
- Q&A
Break (10 mins)
Segment 5: Advanced Testing with pytest
and hypothesis
(50 mins)
- How do I go beyond simple, brittle oracular tests and start using property tests?
- How do I use tools like
pytest
andhypothesis
to write thorough, robust tests for asserting the correctness of my code? - Q&A
Course wrap-up and next steps (10 minutes)
Your Instructor
James Powell
James Powell is a world-renowned expert in data science and open source scientific computing. His subject mastery and guidance are sought after by global organizations for consulting, coaching, and staff training. He is one of the most prolific speakers in the community, and he shares new content each week on his YouTube page, LinkedIn, and Discord.
In addition to O’Reilly Online Learning, James and his team at Don't Use This Code provide Python training and consulting services. He would love to talk to you about how your team uses open source tools for AI/ML - e-mail him at james@dutc.io.
James’s courses are dense and fast-paced. Be sure to stay for the full session and don’t worry if it goes by quickly. You’ll want to re-watch the video later to capture all of the details.