What can you do if your text manipulation in Python is slowing you down? Are there faster alternatives using a compiled extension? This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder’s Weekly articles and projects.
Christopher shares a recent article by Itamar Turner-Trauring called “Speeding Up Text Processing in Python (Is Hard).” The piece compares the performance of string-matching scenarios using several alternatives to pure Python that rely on compiled extensions.
We also discuss a recent Real Python tutorial by Stephen Gruppetta on when to use .__repr__() vs .__str__() in Python. We cover the use cases for these special methods and the intended audiences for the strings they produce.
We share several other articles and projects from the Python community, including a news update, an article on the functional power of Python’s reduce(), a call to ban 1+N in Django, a friendly project to fetch your data files, and a tool for tracking your work from the shell.
Course Spotlight: Unicode in Python: Working With Character Encodings
In this course, you’ll get a Python-centric introduction to character encodings and Unicode. Handling character encodings and numbering systems can at times seem painful and complicated, but this guide is here to help with easy-to-follow Python examples.
Topics:
- 00:00:00 – Introduction
- 00:02:11 – The Python Package Index Launches a Blog
- 00:03:11 – PEP 582 (Python Local Packages Directory) Rejected
- 00:05:00 – Django 4.2 Release Candidate 1 Released
- 00:05:34 – Want to Host DjangoCon Europe 2024?
- 00:06:23 – When Should You Use .__repr__() vs .__str__() in Python?
- 00:14:16 – Sponsor: Snyk
- 00:15:06 – Speeding Up Text Processing in Python (Is Hard)
- 00:22:21 – reduce() - The Power of a Single Python Function
- 00:30:27 – Video Course Spotlight
- 00:32:04 – Ban 1+N in Django
- 00:35:26 – Pooch - A Friend to Fetch Your Data Files
- 00:39:11 – workedon - Track Your Work From the Shell
- 00:41:53 – Thanks and Goodbye
News:
- The Python Package Index Launches a Blog
- PEP 582 (Python Local Packages Directory) Rejected
- Django 4.2 Release Candidate 1 Released
- Want to Host DjangoCon Europe 2024?
Show Links:
- When Should You Use .__repr__() vs .__str__() in Python? – In this tutorial, you’ll learn the difference between the string representations returned by .__repr__() vs .__str__() and understand how to use them effectively in classes that you define.
- Speeding Up Text Processing in Python (Is Hard) – If you need to speed up string parsing and formatting in Python, you have many choices. This article covers the uses of Cython, mypyc, Rust, and PyPy and considers how to choose between them.
- reduce() - The Power of a Single Python Function – “While Python is not a pure functional programming language, you still can do a lot of functional programming in it. In fact, just one function - reduce() - can do most of it.” This article introduces you to reduce().
- Ban 1+N in Django – The 1+N database anti-pattern is common: fetch some rows from the database then re-fetch specific rows to get all the items. An ORM can hide this away and make you fail to realize that it’s happening. This article discusses how to avoid this anti-pattern in Django. It also has an added meta-bonus: a link to the attempt to write the article with ChatGPT.
Projects:
- Pooch: A Friend to Fetch Your Data Files
- workedon: Track Your Work From the Shell
Additional Links:
- Python’s reduce(): From Functional to Pythonic Style – Real Python
- Episode #116: Exploring Functional Programming in Python With Bruce Eckel – The Real Python Podcast
- Lightning talk at PyCascades 2023 - Pooch: A friend to fetch your data files - YouTube
- Secure copy protocol - Wikipedia
Level up your Python skills with our expert-led courses:
- Python's map() Function: Transforming Iterables
- Python Basics: Strings and String Methods
- Unicode in Python: Working With Character Encodings
Support the podcast & join our community of Pythonistas