Episode 171: Making Each Line of Code Efficient & Python In Excel
The Real Python Podcast
Sep 08, 2023 50m
Are you writing efficient Python with as few lines of code as possible? Are you familiar with the many built-in language features that will simplify your code and make it more Pythonic? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder’s Weekly articles and projects.
We discuss a recent post from Bob Belderbos titled “Make Each Line Count, Keeping Things Simple in Python.” We provide many of our favorite Pythonic examples and the language mistakes that we’ve learned from. We also share multiple resources to add to your learning path.
Microsoft has announced a limited beta program for Python in Excel. We dig into the current details, requirements, and potential use cases.
We cover several other articles and projects from the Python community, including a group of announcements from the Python Software Foundation, a showcase of the Polars DataFrame library, immortal objects in Python, a code image generator Python project, an MS Paint clone in the terminal, and a Django ORM cheatsheet.
Course Spotlight: Process Images Using the Pillow Library and Python
In this video course, you’ll learn how to use the Python Pillow library to deal with images and perform image processing. You’ll also explore using NumPy for further processing, including to create animations.
Topics:
- 00:00:00 – Introduction
- 00:02:10 – Python 3.12.0 release candidate 1 released
- 00:02:53 – PSF Announces New PyPI Safety & Security Engineer
- 00:03:44 – 2022 PSF Annual Report
- 00:04:13 – Pydantic has been downloaded … 1 BILLION times!
- 00:04:28 – Python Polars: A Lightning-Fast DataFrame Library
- 00:12:26 – Introducing Immortal Objects for Python
- 00:15:32 – Video Course Spotlight
- 00:17:01 – Introducing Python in Excel
- 00:26:34 – Build a Code Image Generator With Python
- 00:31:49 – Make Each Line Count, Keeping Things Simple in Python
- 00:44:08 – Textual-paint
- 00:46:04 – Django ORM Cheatsheet
- 00:49:48 – Thanks and goodbye
News:
- Python Insider: Python 3.12.0 release candidate 1 released – “The second candidate (and the last planned release preview) is scheduled for Monday, 2023-09-04, while the official release of 3.12.0 is scheduled for Monday, 2023-10-02.”
- Python 3.11.5, 3.10.13, 3.9.18, and 3.8.18 is now available - Python Insider
- PSF Announces New PyPI Safety & Security Engineer
- 2022 PSF Annual Report – The annual report from the Python Software Foundation details all the changes and events at the PSF last year.
- Pydantic has been downloaded … 1 BILLION times! - Twitter
Show Links:
- Python Polars: A Lightning-Fast DataFrame Library – Welcome to the world of Polars, a powerful DataFrame library for Python! In this showcase tutorial, you’ll get a hands-on introduction to Polars’ core features and see why this library is catching so much buzz.
- Introducing Immortal Objects for Python – This article explains immortal objects (PEP 683), which are excluded from garbage collection. This causes performance and shared memory improvements for large architectures.
- Introducing Python in Excel – Microsoft has announced that they’re embedding Python in Excel through a partnership with Anaconda. Read on for details.
- Build a Code Image Generator With Python – In this step-by-step tutorial, you’ll build a code image generator that creates nice-looking images of your code snippets to share on social media. Your code image generator will be powered by the Flask web framework and include exciting packages like Pygments and Playwright.
Discussion:
- Make Each Line Count, Keeping Things Simple in Python – Simplicity is hard. This article talks briefly about how you approach coding while keeping things simple.
- itertools — Functions creating iterators for efficient looping — Python documentation
- More Itertools - more-itertools 10.1.0 documentation
- Python
enumerate()
: Simplify Loops That Need Counters – Real Python - Python’s
all()
: Check Your Iterables for Truthiness – Real Python - How to Use
any()
in Python – Real Python
Projects:
Additional Links:
- Release Python Polars 0.19.0 · pola-rs/polars
- Episode #140: Speeding Up Your DataFrames With Polars – The Real Python Podcast
- Episode #167: Exploring pandas 2.0 & Targets for Apache Arrow – The Real Python Podcast
- Introducing Python in Excel 😱 - YouTube
- Source code beautifier / syntax highlighter – convert code snippets to HTML « hilite.me