Fun with Python's newer tools
summary
Demos show concrete tools and recipes: collections.Counter is a dict subclass that returns zero for missing keys, offers elements() and most_common(n), supports arithmetic including negative counts and a saturating subtraction variant, and the implementation is a few lines. namedtuple gives zero extra memory, a replace() method for prototype/defaults and easy subclassing with __slots__. A decorator lru_cache bounds caches (fibo(100) reduces calls to 101), and the new str.format supports attribute/index lookup and a thousands separator.
AI-written summary · about
chapters (18)
- 0:00Introduction
- 2:37Collections Counter
- 8:01Results Counter
- 8:58Word Count
- 10:14Most Common
- 12:34Least Common
- 15:21Saturation Subtraction
- 17:04Name tuples
- 21:41Test results
- 25:43Convenience methods
- 29:52Pro tip 1
- 30:56Pro tip 2
- 34:36My opinion
- 36:33Cache
- 41:03Dynamic Programming
- 43:51FiboCover
- 46:16String Formatting
- 53:51Previous Slides








