Episode 68: Exploring the functools Module and Complex Numbers in Python
The Real Python Podcast
Jul 09, 2021 55m
Are you ready to expand your Python knowledge into the intermediate to advanced territory? What tools are awaiting your discovery inside Python’s functools module? This week on the show, David Amos is back, and he’s brought another batch of PyCoder’s Weekly articles and projects.
Episode Sponsor:
We discuss an article about the functools module, which adds functionality for caching, function overloading, better definitions for decorated functions, and more. David talks about a new Real Python article about working with complex numbers in Python. We also cover a tutorial about troubleshooting memory problems in Python.
We cover several other articles and projects from the Python community including, DevOps interview questions, correlation analysis in Python, pivot and plot data with pandas, how to use Python and OpenCV to play online chess with a real chessboard, and generating hardware pinout diagrams as SVG images.
Course Spotlight: Python Decorators 101
In this course on Python decorators, you’ll learn what they are and how to create and use them. Decorators provide a simple syntax for calling higher-order functions in Python. By definition, a decorator is a function that takes another function and extends the behavior of the latter function without explicitly modifying it.
Topics:
- 00:00:00 – Introduction
- 00:01:56 – The Future of FastAPI and Pydantic Is Bright
- 00:04:33 – Simplify Complex Numbers With Python
- 00:10:37 – Functools: The Power of Higher-Order Functions in Python
- 00:18:40 – Sponsor: Sentry
- 00:19:42 – How to Pivot and Plot Data With Pandas
- 00:23:06 – devops-exercises: DevOps Interview Questions
- 00:32:09 – Video Course Spotlight
- 00:33:25 – Correlation Analysis 101 in Python
- 00:39:28 – How to Troubleshoot Memory Problems in Python
- 00:46:16 – Use Python and OpenCV to Play Online Chess With a Real Chessboard
- 00:49:28 – pinout: Generate Hardware Pinout Diagrams as SVG Images
- 00:54:21 – Thanks and goodbyes
Show Links:
The Future of FastAPI and Pydantic Is Bright – Not long ago there was some chatter on the internet about a change in Python 3.10 that would impact Python projects that check types at runtime. The discussion centered around FastAPI and Pydantic and had some folks worried about the future of those projects. In this article, FastAPI’s creator explains what the discussion was all about and why the future of FastAPI and Pydantic remains bright.
Simplify Complex Numbers With Python – In this tutorial, you’ll learn about the unique treatment of complex numbers in Python. Complex numbers are a convenient tool for solving scientific and engineering problems. You’ll experience the elegance of using complex numbers in Python with several hands-on examples.
Functools: The Power of Higher-Order Functions in Python – The functools
module is one of the “hidden gems” of the Python standard library. This article takes you on a tour of everything in functools
. You’ll learn how to implement caching, function overloading, and a whole lot more.
How to Pivot and Plot Data With Pandas – One of the challenges of working with data is knowing how to manipulate the data format for a particular analysis. And there’s no single correct format. You need to know how to melt, pivot, and transpose data into a format that fits whatever you’re analyzing. If you enjoy this article, be sure to also check out Stefanie’s Pandas Workshop.
devops-exercises: DevOps Interview Questions
Correlation Analysis 101 in Python – Correlation analysis is a useful part of exploratory data analysis. It can help you identify potential relationships between various features of your data. In this helpful guide, you’ll learn how to do correlation analysis in a pandas DataFrame
. You’ll see how to display a correlation matrix as a heatmap and explore some guidelines for identifying when correlation might imply causation.
How to Troubleshoot Memory Problems in Python – Memory problems can be frustrating. They’re hard to diagnose and fix, and memory issues in Python applications can be especially frustrating thanks to the language’s garbage collection system. In this article, you’ll learn a six-step process for troubleshooting memory problems that the EvalML team used to solve a tricky problem with their library.
Projects:
- play-online-chess-with-real-chess-board: Use Python and OpenCV to Play Online Chess With a Real Chessboard
- pinout: Generate Hardware Pinout Diagrams as SVG Images
Additional Links:
- functools: Python 3 Documentation
- Primer on Python Decorators: Real Python Guide
- Caching in Python Using the LRU Cache Strategy: Real Python Article
- Caching in Python With lru_cache: Real Python Video Course
- Measuring Memory Usage in Python: It’s Tricky!
- Fritzing: Electronics Made Easy
- KiCad EDA: A Cross Platform and Open Source Electronics Design Automation Suite
- PcbDraw: Convert your KiCAD boards into nice looking 2D drawings
- Four stages of competence: Wikipedia article